nlcpy.random.RandomState.randn

RandomState.randn(self, size)

Returns a sample (or samples) from the “standard normal” distribution.

If positive int_like arguments are provided, randn generates an array of shape (d0, d1, ..., dn), filled with random floats sampled from a univariate “normal” (Gaussian) distribution of mean 0 and variance 1.

Parameters
sizeint or tuple of ints, optional

The dimensions of the returned array, must be non-negative.

Returns
Zndarray

A (d0, d1, ..., dn)-shaped array of floating-point samples from the standard normal distribution, or a single such float if no parameters were supplied.

See also

RandomState.standard_normal

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

RandomState.normal

Draws random samples from a normal (Gaussian) distribution.

Note

For random samples from N(\mu, \sigma^2), use:

sigma * vp.random.randn(...) + mu

Examples

>>> import nlcpy as vp
>>> vp.random.randn()   
array(0.54214143)  # random

Two-by-four array of samples from N(3, 6.25):

>>> 3 + 2.5 * vp.random.randn(2, 4) 
array([[-4.49401501,  4.00950034, -1.81814867,  7.29718677],   # random
       [ 0.39924804,  4.68456316,  4.99394529,  4.84057254]])  # random