@@ -662,9 +662,9 @@ cdef class RandomState:
662662 self .get_state ())
663663
664664 # Basic distributions:
665- def random_sample (self , size = None , dtype = np .float64 ):
665+ def random_sample (self , size = None , dtype = np .float64 , out = None ):
666666 """
667- random_sample(size=None, dtype='d')
667+ random_sample(size=None, dtype='d', out=None )
668668
669669 Return random floats in the half-open interval [0.0, 1.0).
670670
@@ -684,6 +684,10 @@ cdef class RandomState:
684684 Desired dtype of the result. All dtypes are determined by their
685685 name, either 'float64' or 'float32'. The default value is
686686 'float64'.
687+ out : ndarray, optional
688+ Alternative output array in which to place the result. If size is not None,
689+ it must have the same shape as the provided size and must match the type of
690+ the output values.
687691
688692 Returns
689693 -------
@@ -710,9 +714,9 @@ cdef class RandomState:
710714 """
711715 key = np .dtype (dtype ).name
712716 if key == 'float64' :
713- return double_fill (& self .rng_state , & random_uniform_fill_double , size , self .lock )
717+ return double_fill (& self .rng_state , & random_uniform_fill_double , size , self .lock , out )
714718 elif key == 'float32' :
715- return float_fill (& self .rng_state , & random_uniform_fill_float , size , self .lock )
719+ return float_fill (& self .rng_state , & random_uniform_fill_float , size , self .lock , out )
716720 else :
717721 raise TypeError ('Unsupported dtype "%s" for random_sample' % key )
718722
@@ -1403,9 +1407,10 @@ cdef class RandomState:
14031407
14041408
14051409 # Complicated, continuous distributions:
1406- def standard_normal (self , size = None , dtype = np .float64 , method = __normal_method ):
1410+ def standard_normal (self , size = None , dtype = np .float64 , method = __normal_method ,
1411+ out = None ):
14071412 """
1408- standard_normal(size=None, dtype='d', method='bm')
1413+ standard_normal(size=None, dtype='d', method='bm', out=None )
14091414
14101415 Draw samples from a standard Normal distribution (mean=0, stdev=1).
14111416
@@ -1422,6 +1427,10 @@ cdef class RandomState:
14221427 method : str, optional
14231428 Either 'bm' or 'zig'. 'bm' uses the default Box-Muller transformations
14241429 method. 'zig' uses the much faster Ziggurat method of Marsaglia and Tsang.
1430+ out : ndarray, optional
1431+ Alternative output array in which to place the result. If size is not None,
1432+ it must have the same shape as the provided size and must match the type of
1433+ the output values.
14251434
14261435 Returns
14271436 -------
@@ -1440,26 +1449,22 @@ cdef class RandomState:
14401449 >>> s.shape
14411450 (3, 4, 2)
14421451
1443- Notes
1444- -----
1445- float32 normals are only available using the Box-Muller transformation
1446-
14471452 """
14481453 key = np .dtype (dtype ).name
14491454 if key == 'float64' :
14501455 if method == u'zig' :
14511456 return double_fill (& self .rng_state , & random_gauss_zig_double_fill ,
1452- size , self .lock )
1457+ size , self .lock , out )
14531458 else :
14541459 return double_fill (& self .rng_state , & random_gauss_fill ,
1455- size , self .lock )
1460+ size , self .lock , out )
14561461 elif key == 'float32' :
14571462 if method == u'zig' :
14581463 return float_fill (& self .rng_state , & random_gauss_zig_float_fill ,
1459- size , self .lock )
1464+ size , self .lock , out )
14601465 else :
14611466 return float_fill (& self .rng_state , & random_gauss_fill_float ,
1462- size , self .lock )
1467+ size , self .lock , out )
14631468 else :
14641469 raise TypeError ('Unsupported dtype "%s" for standard_normal' % key )
14651470
@@ -1663,9 +1668,9 @@ cdef class RandomState:
16631668 0.0 , '' , CONS_NONE ,
16641669 0.0 , '' , CONS_NONE )
16651670
1666- def standard_exponential (self , size = None , dtype = np .float64 ):
1671+ def standard_exponential (self , size = None , dtype = np .float64 , out = None ):
16671672 """
1668- standard_exponential(size=None, dtype=np.float64)
1673+ standard_exponential(size=None, dtype=np.float64, out=None )
16691674
16701675 Draw samples from the standard exponential distribution.
16711676
@@ -1682,6 +1687,10 @@ cdef class RandomState:
16821687 Desired dtype of the result. All dtypes are determined by their
16831688 name, either 'float64' or 'float32'. The default value is
16841689 'float64'.
1690+ out : ndarray, optional
1691+ Alternative output array in which to place the result. If size is not None,
1692+ it must have the same shape as the provided size and must match the type of
1693+ the output values.
16851694
16861695 Returns
16871696 -------
@@ -1699,11 +1708,11 @@ cdef class RandomState:
16991708 if key == 'float64' :
17001709 return double_fill (& self .rng_state ,
17011710 & random_standard_exponential_fill_double ,
1702- size , self .lock )
1711+ size , self .lock , out )
17031712 elif key == 'float32' :
17041713 return float_fill (& self .rng_state ,
17051714 & random_standard_exponential_fill_float ,
1706- size , self .lock )
1715+ size , self .lock , out )
17071716 else :
17081717 raise TypeError ('Unsupported dtype "%s" for standard_exponential'
17091718 % key )
0 commit comments