ó
£áSc           @` s¿  d  Z  d d l m Z m Z m Z d d d d d d d	 d
 d d d d d d d d d d d d d d d g Z e Z d d l j	 j
 Z d d l Z d d d „ Z d „  Z g  d „ Z	 g  d „ Z d g  d „ Z d  g  d! „ Z d" „  Z g  d# „ Z g  d$ „ Z g  d% „ Z g  d& „ Z g  d' „ Z g  d( „ Z g  d) „ Z g  d* „ Z g  d+ „ Z g  d, „ Z g  d- „ Z g  d. „ Z  g  d/ „ Z! g  d0 „ Z" g  d1 „ Z# d2 „  Z$ e% d3 k r»e$ ƒ  n  d S(4   s,   Backward compatible module for RandomArray

i    (   t   divisiont   absolute_importt   print_functiont   ArgumentErrort   Ft   betat   binomialt
   chi_squaret   exponentialt   gammat   get_seedt   mean_var_testt   multinomialt   multivariate_normalt   negative_binomialt   noncentral_Ft   noncentral_chi_squaret   normalt   permutationt   poissont   randintt   randomt   random_integerst   seedt   standard_normalt   uniformNc         C` s<   |  d k s | d k r% t  j ƒ  n t  j |  | f ƒ d  S(   Ni    (   t   mtR   (   t   xt   y(    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR      s    c           C` s   t  d ƒ ‚ d  S(   Nsš   If you want to save the state of the random number generator.
Then you should use obj = numpy.random.get_state() followed by.
numpy.random.set_state(obj).(   t   NotImplementedError(    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR
      s    c         C` s"   |  g  k r d }  n  t j |  ƒ S(   s@   random(n) or random([n, m, ...]) returns array of random numbersN(   t   NoneR   t   random_sample(   t   shape(    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR      s    	c         C` s(   | g  k r d } n  t j |  | | ƒ S(   sc   uniform(minimum, maximum, shape=[]) returns array of given shape of random reals
    in given rangeN(   R   R   R   (   t   minimumt   maximumR    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   $   s    	c         C` s£   t  |  t ƒ s t d ƒ ‚ n  | d k r9 |  } d }  n  t  | t ƒ sW t d ƒ ‚ n  | |  t | ƒ } t  | t j ƒ r‘ |  | j t j ƒ S|  t | ƒ Sd S(   sk   randint(min, max, shape=[]) = random integers >=min, < max
    If max not given, random integers >= 0, <mins'   randint requires first argument integeri    s(   randint requires second argument integerN(   t
   isinstancet   intR   R   R   t   npt   ndarrayt   astype(   R!   R"   R    t   a(    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   +   s    	i   c         C` s   t  | |  d | ƒ S(   sR   random_integers(max, min=1, shape=[]) = random integers in range min-max inclusivei   (   R   (   R"   R!   R    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   ;   s    c         C` s   t  j |  ƒ S(   s2   permutation(n) = a permutation of indices range(n)(   R   R   (   t   n(    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   ?   s    c         C` s"   |  g  k r d }  n  t j |  ƒ S(   s¢   standard_normal(n) or standard_normal([n, m, ...]) returns array of
           random numbers normally distributed with mean 0 and standard
           deviation 1N(   R   R   R   (   R    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   C   s    	c         C` s(   | g  k r d } n  t j |  | | ƒ S(   sž   normal(mean, std, n) or normal(mean, std, [n, m, ...]) returns
    array of random numbers randomly distributed with specified mean and
    standard deviationN(   R   R   R   (   t   meant   stdR    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   K   s    	c         C` s(   | g  k r d } n  t j |  | | ƒ S(   sU  multivariate_normal(mean, cov) or multivariate_normal(mean, cov, [m, n, ...])
    returns an array containing multivariate normally distributed random numbers
    with specified mean and covariance.

    mean must be a 1 dimensional array. cov must be a square two dimensional
    array with the same number of rows and columns as mean has elements.

    The first form returns a single 1-D array containing a multivariate
    normal.

    The second form returns an array of shape (m, n, ..., cov.shape[0]).
    In this case, output[i,j,...,:] is a 1-D array containing a multivariate
    normal.N(   R   R   R   (   R*   t   covR    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   S   s    	c         C` s%   | g  k r d } n  t j |  | ƒ S(   sŠ   exponential(mean, n) or exponential(mean, [n, m, ...]) returns array
      of random numbers exponentially distributed with specified meanN(   R   R   R   (   R*   R    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   e   s    	c         C` s(   | g  k r d } n  t j |  | | ƒ S(   sW   beta(a, b) or beta(a, b, [n, m, ...]) returns array of beta distributed random numbers.N(   R   R   R   (   R(   t   bR    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   l   s    	c         C` s(   | g  k r d } n  t j |  | | ƒ S(   sZ   gamma(a, r) or gamma(a, r, [n, m, ...]) returns array of gamma distributed random numbers.N(   R   R   R	   (   R(   t   rR    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR	   r   s    	c         C` s(   | g  k r d } n  t j |  | | ƒ S(   s±   F(dfn, dfd) or F(dfn, dfd, [n, m, ...]) returns array of F distributed random numbers with dfn degrees of freedom in the numerator and dfd degrees of freedom in the denominator.N(   R   R   t   f(   t   dfnt   dfdR    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   x   s    	c         C` s+   | g  k r d } n  t j |  | | | ƒ S(   s  noncentral_F(dfn, dfd, nonc) or noncentral_F(dfn, dfd, nonc, [n, m, ...]) returns array of noncentral F distributed random numbers with dfn degrees of freedom in the numerator and dfd degrees of freedom in the denominator, and noncentrality parameter nconc.N(   R   R   t   noncentral_f(   R0   R1   t   nconcR    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   ~   s    	c         C` s%   | g  k r d } n  t j |  | ƒ S(   s�   chi_square(df) or chi_square(df, [n, m, ...]) returns array of chi squared distributed random numbers with df degrees of freedom.N(   R   R   t	   chisquare(   t   dfR    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   „   s    	c         C` s(   | g  k r d } n  t j |  | | ƒ S(   sÁ   noncentral_chi_square(df, nconc) or chi_square(df, nconc, [n, m, ...]) returns array of noncentral chi squared distributed random numbers with df degrees of freedom and noncentrality parameter.N(   R   R   t   noncentral_chisquare(   R5   R3   R    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   Š   s    	c         C` s(   | g  k r d } n  t j |  | | ƒ S(   s  binomial(trials, p) or binomial(trials, p, [n, m, ...]) returns array of binomially distributed random integers.

           trials is the number of trials in the binomial distribution.
           p is the probability of an event in each trial of the binomial distribution.N(   R   R   R   (   t   trialst   pR    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   �   s    	c         C` s(   | g  k r d } n  t j |  | | ƒ S(   sI  negative_binomial(trials, p) or negative_binomial(trials, p, [n, m, ...]) returns
           array of negative binomially distributed random integers.

           trials is the number of trials in the negative binomial distribution.
           p is the probability of an event in each trial of the negative binomial distribution.N(   R   R   R   (   R7   R8   R    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   ™   s    	c         C` s(   | g  k r d } n  t j |  | | ƒ S(   sé  multinomial(trials, probs) or multinomial(trials, probs, [n, m, ...]) returns
           array of multinomial distributed integer vectors.

           trials is the number of trials in each multinomial distribution.
           probs is a one dimensional array. There are len(prob)+1 events.
           prob[i] is the probability of the i-th event, 0<=i<len(prob).
           The probability of event len(prob) is 1.-np.sum(prob).

       The first form returns a single 1-D array containing one multinomially
           distributed vector.

           The second form returns an array of shape (m, n, ..., len(probs)).
           In this case, output[i,j,...,:] is a 1-D array containing a multinomially
           distributed integer 1-D array.N(   R   R   R   (   R7   t   probsR    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   £   s    	c         C` s%   | g  k r d } n  t j |  | ƒ S(   s€   poisson(mean) or poisson(mean, [n, m, ...]) returns array of poisson
           distributed random integers with specified mean.N(   R   R   R   (   R*   R    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   ¶   s    	c   
      C` sß   t  |  ƒ d } t j |  d d ƒ| } |  | } t j | | d d ƒ| d } t d t  |  ƒ | ƒ t d | d | ƒ t d | d | ƒ | g  k rÛ t j | | | d d ƒd | d }	 t d | d |	 ƒ n  d  S(   Ng      ð?t   axisi    s   
Average of s   (should be about s   ):s2   Variance of those random numbers (should be about g     ‡Ã@g      @g       @s2   Skewness of those random numbers (should be about g      ø?(   t   lenR%   t   sumt   print(
   R   t   typeR*   t   vart   skewR)   t   x_meant   x_minus_meant   x_vart   x_skew(    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyR   ¾   s    
!)c       	   C` sÌ  t  j ƒ  }  t  j |  ƒ t  j ƒ  } | d |  d j ƒ  rL t d ƒ ‚ n  t d t ƒ  ƒ t d t j t d ƒ d d ƒd ƒ t d	 d
 g ƒ } t	 | j
 ƒ d k sÏ | j
 d d	 k sÏ | j
 d d
 k rÞ t d ƒ ‚ n  dB | _
 t d t j | d d ƒd ƒ t d d dC ƒ } t	 | j
 ƒ d k sT| j
 d d
 k sT| j
 d d	 k rct d ƒ ‚ n  dD | _
 t j j | ƒ d k sœt j j | ƒ d k r«t d ƒ ‚ n  t d ƒ t t d d	 d d g ƒƒ t d t d	 ƒ ƒ t d t d d ƒ ƒ t d ƒ t t d	 d d g ƒƒ d } t d | d	 d
 g ƒ } t	 | j
 ƒ d k sv| j
 d d	 k sv| j
 d d
 k r…t d ƒ ‚ n  dE | _
 t | d | d f d | d d ƒ t d d ƒ } t | d | f | | d d ƒ t t j d	 d g ƒ t j d d g d d  g f ƒ ƒ } t d! | ƒ | j
 dF k rGt d" ƒ ‚ n  t t j d	 d g ƒ t j d d g d d  g g ƒ d  d g ƒ } t d# ƒ t | ƒ | j
 dG k r»t d" ƒ ‚ n  t t j d$ d d% g ƒ t j d d d g d d d g d d d g g ƒ d ƒ } t j | d d ƒd } t d& ƒ t | ƒ | | } t d' ƒ t t j t j | ƒ | ƒ d( ƒ t d) d* d ƒ } t | d+ d, d- ƒ t d. d d ƒ } t | d/ dH dJ ƒ t d0 d ƒ } t | d1 d2 d3 d t j dK ƒ ƒ t d) d* d ƒ } t | d4 d5 d6 ƒ t d7 d ƒ } t | d8 d d d9 ƒ t d: ƒ t t d; d d; ƒ ƒ t d< ƒ t t  d; d d; g ƒ ƒ t d= ƒ t! d; d> d d> g d? ƒ } t | ƒ t d@ t j | d d ƒdA ƒ d  S(L   Ni   s   Failed seed test.s   First random number iss"   Average of 10000 random numbers isi'  R:   i    g     ˆÃ@i
   iè  i   s   random returned wrong shapes'   Average of 100 by 100 random numbers isg      à?g333333ã?s   uniform returned wrong shapes%   uniform returned out of desired ranges   randint(1, 10, shape=[50])R    i2   s   permutation(10)s   randint(3,9)i   i	   s   random_integers(10, shape=[20])i   g      @g       @s$   standard_normal returned wrong shapes8   normally distributed numbers with mean 2 and variance %fs5   random numbers exponentially distributed with mean %fi   s   
A multivariate normals(   multivariate_normal returned wrong shapes-   A 4x3x2 array containing multivariate normalsiœÿÿÿid   s<   Average of 10000 multivariate normals with mean [-100,0,100]s\   Estimated covariance of 10000 multivariate normals with covariance [[3,2,1],[2,2,1],[1,1,1]]g    €‡Ã@g      @g      $@s   beta(5.,10.) random numbersgZd;ßOÕ?gyé&1¬Œ?g{®Gáz„?s   gamma(.01,2.) random numbersg      &@s5   chi squared random numbers with 11 degrees of freedomi   i   s1   F random numbers with 5 and 10 degrees of freedomg      ô?gš™™™™™õ?g      I@s#   poisson random numbers with mean 50gìQ¸…ëÁ?sG   
Each element is the result of 16 binomial trials with probability 0.5:i   sP   
Each element is the result of 16 negative binomial trials with probability 0.5:sX   
Each row is the result of 16 multinomial trials with probabilities [0.1, 0.5, 0.1 0.3]:gš™™™™™¹?i   s   Mean = g       @(   i'  (   iè  i
   (   i'  (   i'  (   i   (   i   i   i   iÈ   iÈ   i N  gF]tÑEÇ?("   R   t	   get_statet	   set_statet   anyt
   SystemExitR=   R   R%   R<   R;   R    R   R!   t   reduceR"   R   R   R   R   R   R   R   t   arrayt   dott	   transposeR   R	   R   t   sqrtR   R   R   R   R   (   t   objt   obj2R   R   t   sRA   RB   (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyt   testÊ   s„    &;	 ;	0

;	%!9 B

 Q



##



t   __main__(&   t   __doc__t
   __future__R    R   R   t   __all__t
   ValueErrorR   t   numpy.random.mtrandR   t   mtrandR   t   numpyR%   R   R
   R   R   R   R   R   R   R   R   R   R   R	   R   R   R   R   R   R   R   R   R   RQ   t   __name__(    (    (    sW   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/oldnumeric/random_array.pyt   <module>   sF   					
	B