bundles / numpy 2.4.3 / 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, optionalOutput shape. If the given shape is, e.g.,
(m, n, k), thenm * n * ksamples are drawn. Default is None, in which case a single value is returned.
Returns
out: float or ndarrayA floating-point array of shape
sizeof drawn samples, or a single sample ifsizewas 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
locandscalearguments for setting the mean and standard deviation.- random.Generator.standard_normal
which should be used for new code.
Aliases
numpy.random.standard_normalnumpy.random.RandomState.standard_normal