standard_normal#
- class braincore.random.standard_normal(size=None, key=None, dtype=None)[source]#
Draw samples from a standard Normal distribution (mean=0, stdev=1).
- Parameters:
size (int or tuple of ints, optional) – Output 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.key (PRNGKey, optional) – The key for the random number generator. If not given, the default random number generator is used.
- Returns:
out – A floating-point array of shape
sizeof drawn samples, or a single sample ifsizewas not specified.- Return type:
float or ndarray
See also
normalEquivalent function with additional
locandscalearguments for setting the mean and standard deviation.
Notes
For random samples from the normal distribution with mean
muand standard deviationsigma, use one of:mu + sigma * braincore.random.standard_normal(size=...) braincore.random.normal(mu, sigma, size=...)
Examples
>>> braincore.random.standard_normal() 2.1923875335537315 #random
>>> s = braincore.random.standard_normal(8000) >>> s array([ 0.6888893 , 0.78096262, -0.89086505, ..., 0.49876311, # random -0.38672696, -0.4685006 ]) # random >>> s.shape (8000,) >>> s = braincore.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 * braincore.random.standard_normal(size=(2, 4)) array([[-4.49401501, 4.00950034, -1.81814867, 7.29718677], # random [ 0.39924804, 4.68456316, 4.99394529, 4.84057254]]) # random