dask 2021.10.0

NotesParametersReturnsBackRef
normal(self, loc=0.0, scale=1.0, size=None, chunks='auto', **kwargs)

This docstring was copied from numpy.random.mtrand.RandomState.normal.

Some inconsistencies with the Dask version may exist.

The probability density function of the normal distribution, first derived by De Moivre and 200 years later by both Gauss and Laplace independently , is often called the bell curve because of its characteristic shape (see the example below).

The normal distributions occurs often in nature. For example, it describes the commonly occurring distribution of samples influenced by a large number of tiny, random disturbances, each with its own unique distribution .

note

New code should use the normal method of a default_rng() instance instead; please see the :None:ref:`random-quick-start`.

Notes

The probability density for the Gaussian distribution is

$$p(x) = \frac{1}{\sqrt{ 2 \pi \sigma^2 }}e^{ - \frac{ (x - \mu)^2 } {2 \sigma^2} },$$

where $\mu$ is the mean and $\sigma$ the standard deviation. The square of the standard deviation, $\sigma^2$ , is called the variance.

The function has its peak at the mean, and its "spread" increases with the standard deviation (the function reaches 0.607 times its maximum at $x + \sigma$ and $x - \sigma$ ). This implies that normal is more likely to return samples lying close to the mean, rather than those far away.

Parameters

loc : float or array_like of floats

Mean ("centre") of the distribution.

scale : float or array_like of floats

Standard deviation (spread or "width") of the distribution. Must be non-negative.

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. If size is None (default), a single value is returned if loc and scale are both scalars. Otherwise, np.broadcast(loc, scale).size samples are drawn.

Returns

out : ndarray or scalar

Drawn samples from the parameterized normal distribution.

Draw random samples from a normal (Gaussian) distribution.

See Also

Generator.normal

which should be used for new code.

scipy.stats.norm

probability density function, distribution or cumulative density function, etc.

Examples

Draw samples from the distribution:

This example is valid syntax, but we were not able to check execution
>>> mu, sigma = 0, 0.1 # mean and standard deviation  # doctest: +SKIP
... s = np.random.normal(mu, sigma, 1000) # doctest: +SKIP

Verify the mean and the variance:

This example is valid syntax, but we were not able to check execution
>>> abs(mu - np.mean(s))  # doctest: +SKIP
0.0  # may vary
This example is valid syntax, but we were not able to check execution
>>> abs(sigma - np.std(s, ddof=1))  # doctest: +SKIP
0.1  # may vary

Display the histogram of the samples, along with the probability density function:

This example is valid syntax, but we were not able to check execution
>>> import matplotlib.pyplot as plt  # doctest: +SKIP
... count, bins, ignored = plt.hist(s, 30, density=True) # doctest: +SKIP
... plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) * # doctest: +SKIP
...  np.exp( - (bins - mu)**2 / (2 * sigma**2) ),
...  linewidth=2, color='r')
... plt.show() # doctest: +SKIP

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

This example is valid syntax, but we were not able to check execution
>>> np.random.normal(3, 2.5, size=(2, 4))  # doctest: +SKIP
array([[-4.49401501,  4.00950034, -1.81814867,  7.29718677],   # random
       [ 0.39924804,  4.68456316,  4.99394529,  4.84057254]])  # random
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.array.gufunc.apply_gufunc dask.array.random.RandomState dask.array.gufunc.as_gufunc dask.array.gufunc.gufunc dask.array.random.RandomState.standard_normal

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/random.py#350
type: <class 'function'>
Commit: