This is a pre-release version (2.5.0.dev0+git20251130.2de293a).Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / random / RandomState / standard_normal

cython_function_or_method

numpy.random:RandomState.standard_normal

Signature

def standard_normal(size = None)

Summary

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

Extended Summary

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.

Returns

out : float or ndarray

A floating-point array of shape size of drawn samples, or a single sample if size was not specified.

Notes

For random samples from the normal distribution with mean mu and standard deviation sigma, use one of

mu + sigma * np.random.standard_normal(size=...)
np.random.normal(mu, sigma, size=...)

Examples

np.random.standard_normal()
✗
-1.4605549319534663
s = np.random.standard_normal(8000)
✓
s
✗
array([ 0.72207177, -0.431767  , -0.97062797, ..., -0.76863801,
        2.21979488, -1.12869481], shape=(8000,))
s.shape
s = np.random.standard_normal(size=(3, 4, 2))
s.shape
✓
(3, 4, 2)
Two-by-four array of samples from the normal distribution with mean 3 and standard deviation 2.5:
3 + 2.5 * np.random.standard_normal(size=(2, 4))
✗
array([[6.49528847, 0.51320294, 4.90665838, 2.60873479],
       [2.10450704, 5.5719306 , 1.26342294, 3.55496605]])

See also

normal

Equivalent function with additional loc and scale arguments for setting the mean and standard deviation.

random.Generator.standard_normal

which should be used for new code.

Aliases

  • numpy.random.standard_normal
  • numpy.random.RandomState.standard_normal