@@ -662,9 +662,9 @@ cdef class RandomState:
662
662
self .get_state ())
663
663
664
664
# Basic distributions:
665
- def random_sample (self , size = None , dtype = np .float64 ):
665
+ def random_sample (self , size = None , dtype = np .float64 , out = None ):
666
666
"""
667
- random_sample(size=None, dtype='d')
667
+ random_sample(size=None, dtype='d', out=None )
668
668
669
669
Return random floats in the half-open interval [0.0, 1.0).
670
670
@@ -684,6 +684,10 @@ cdef class RandomState:
684
684
Desired dtype of the result. All dtypes are determined by their
685
685
name, either 'float64' or 'float32'. The default value is
686
686
'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.
687
691
688
692
Returns
689
693
-------
@@ -710,9 +714,9 @@ cdef class RandomState:
710
714
"""
711
715
key = np .dtype (dtype ).name
712
716
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 )
714
718
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 )
716
720
else :
717
721
raise TypeError ('Unsupported dtype "%s" for random_sample' % key )
718
722
@@ -1403,9 +1407,10 @@ cdef class RandomState:
1403
1407
1404
1408
1405
1409
# 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 ):
1407
1412
"""
1408
- standard_normal(size=None, dtype='d', method='bm')
1413
+ standard_normal(size=None, dtype='d', method='bm', out=None )
1409
1414
1410
1415
Draw samples from a standard Normal distribution (mean=0, stdev=1).
1411
1416
@@ -1422,6 +1427,10 @@ cdef class RandomState:
1422
1427
method : str, optional
1423
1428
Either 'bm' or 'zig'. 'bm' uses the default Box-Muller transformations
1424
1429
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.
1425
1434
1426
1435
Returns
1427
1436
-------
@@ -1440,26 +1449,22 @@ cdef class RandomState:
1440
1449
>>> s.shape
1441
1450
(3, 4, 2)
1442
1451
1443
- Notes
1444
- -----
1445
- float32 normals are only available using the Box-Muller transformation
1446
-
1447
1452
"""
1448
1453
key = np .dtype (dtype ).name
1449
1454
if key == 'float64' :
1450
1455
if method == u'zig' :
1451
1456
return double_fill (& self .rng_state , & random_gauss_zig_double_fill ,
1452
- size , self .lock )
1457
+ size , self .lock , out )
1453
1458
else :
1454
1459
return double_fill (& self .rng_state , & random_gauss_fill ,
1455
- size , self .lock )
1460
+ size , self .lock , out )
1456
1461
elif key == 'float32' :
1457
1462
if method == u'zig' :
1458
1463
return float_fill (& self .rng_state , & random_gauss_zig_float_fill ,
1459
- size , self .lock )
1464
+ size , self .lock , out )
1460
1465
else :
1461
1466
return float_fill (& self .rng_state , & random_gauss_fill_float ,
1462
- size , self .lock )
1467
+ size , self .lock , out )
1463
1468
else :
1464
1469
raise TypeError ('Unsupported dtype "%s" for standard_normal' % key )
1465
1470
@@ -1663,9 +1668,9 @@ cdef class RandomState:
1663
1668
0.0 , '' , CONS_NONE ,
1664
1669
0.0 , '' , CONS_NONE )
1665
1670
1666
- def standard_exponential (self , size = None , dtype = np .float64 ):
1671
+ def standard_exponential (self , size = None , dtype = np .float64 , out = None ):
1667
1672
"""
1668
- standard_exponential(size=None, dtype=np.float64)
1673
+ standard_exponential(size=None, dtype=np.float64, out=None )
1669
1674
1670
1675
Draw samples from the standard exponential distribution.
1671
1676
@@ -1682,6 +1687,10 @@ cdef class RandomState:
1682
1687
Desired dtype of the result. All dtypes are determined by their
1683
1688
name, either 'float64' or 'float32'. The default value is
1684
1689
'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.
1685
1694
1686
1695
Returns
1687
1696
-------
@@ -1699,11 +1708,11 @@ cdef class RandomState:
1699
1708
if key == 'float64' :
1700
1709
return double_fill (& self .rng_state ,
1701
1710
& random_standard_exponential_fill_double ,
1702
- size , self .lock )
1711
+ size , self .lock , out )
1703
1712
elif key == 'float32' :
1704
1713
return float_fill (& self .rng_state ,
1705
1714
& random_standard_exponential_fill_float ,
1706
- size , self .lock )
1715
+ size , self .lock , out )
1707
1716
else :
1708
1717
raise TypeError ('Unsupported dtype "%s" for standard_exponential'
1709
1718
% key )
0 commit comments