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 / matlib / randn

function

numpy.matlib:randn

source: build-install/usr/lib/python3.14/site-packages/numpy/matlib.py :279

Signature

def   randn ( * args )

Summary

Return a random matrix with data from the "standard normal" distribution.

Extended Summary

randn generates a matrix filled with random floats sampled from a univariate "normal" (Gaussian) distribution of mean 0 and variance 1.

Parameters

\*args : Arguments

Shape of the output. If given as N integers, each integer specifies the size of one dimension. If given as a tuple, this tuple gives the complete shape.

Returns

Z : matrix of floats

A matrix of floating-point samples drawn from the standard normal distribution.

Notes

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

sigma * np.matlib.randn(...) + mu

Examples

np.random.seed(123)
import numpy.matlib
np.matlib.randn(1)
np.matlib.randn(1, 2, 3)
Two-by-four matrix of samples from the normal distribution with mean 3 and standard deviation 2.5:
2.5 * np.matlib.randn((2, 4)) + 3

See also

numpy.random.RandomState.randn
rand

Aliases

  • numpy.matlib.randn