randomstate.prng.mt19937.standard_normal

randomstate.prng.mt19937.standard_normal(size=None, dtype='d', method='bm', out=None)

Draw samples from a standard Normal distribution (mean=0, stdev=1).

Parameters:
  • size (int or tuple of ints, optional) – Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.
  • dtype ({str, dtype}, optional) – Desired dtype of the result, either ‘d’ (or ‘float64’) or ‘f’ (or ‘float32’). All dtypes are determined by their name. The default value is ‘d’.
  • method (str, optional) – Either ‘bm’ or ‘zig’. ‘bm’ uses the default Box-Muller transformations method. ‘zig’ uses the much faster Ziggurat method of Marsaglia and Tsang.
  • out (ndarray, optional) – Alternative output array in which to place the result. If size is not None, it must have the same shape as the provided size and must match the type of the output values.
Returns:

out – Drawn samples.

Return type:

float or ndarray

Examples

>>> s = np.random.standard_normal(8000)
>>> s
array([ 0.6888893 ,  0.78096262, -0.89086505, ...,  0.49876311, #random
       -0.38672696, -0.4685006 ])                               #random
>>> s.shape
(8000,)
>>> s = np.random.standard_normal(size=(3, 4, 2))
>>> s.shape
(3, 4, 2)