numpy.random.randn
Возвращает выборку (или выборки)из «стандартного нормального» распределения.
Это удобная функция для пользователей, переносящих код из Matlab, и она обертывает standard_normal . Эта функция принимает кортеж для указания размера вывода, что согласуется с другими функциями NumPy, такими как numpy.zeros и numpy.ones .
В новом коде вместо этого следует использовать метод standard_normal экземпляра default_rng() ; см. Быстрый старт .
Если предоставлены положительные аргументы типа int_like, randn генерирует массив формы (d0, d1, . dn) , заполненный случайными числами с плавающей запятой, выбранными из одномерного «нормального» (гауссовского) распределения среднего значения 0 и дисперсии 1. Одиночное число с плавающей запятой случайная выборка из распределения возвращается, если аргумент не указан.
Parameters d0, d1, …, dn целое, необязательный
Размеры возвращаемого массива должны быть неотрицательными.Если аргумент не указан,то возвращается один плавающий Python.
Returns Z ndarray или float
(d0, d1, . dn) -образный массив выборок с плавающей запятой от стандартного нормального распределения, или одного такого поплавок , если параметры не были поставлены.
Похоже,но в качестве аргумента принимает кортеж.
Также принимает аргументы mu и sigma.
который следует использовать для нового кода.
Notes
Для случайных выборок из \(N(\mu,\sigma^2)\),используйте:
sigma * np.random.randn(. ) + mu
Examples
>>> np.random.randn() 2.1923875335537315 # random
Двух-четырех массива образцов из N(3,6.25):
>>> 3 + 2.5 * np.random.randn(2, 4) array([[-4.49401501, 4.00950034, -1.81814867, 7.29718677], # random [ 0.39924804, 4.68456316, 4.99394529, 4.84057254]]) # random
numpy.random.randn#
Return a sample (or samples) from the “standard normal” distribution.
This is a convenience function for users porting code from Matlab, and wraps standard_normal . That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones .
New code should use the standard_normal method of a Generator instance instead; please see the Quick Start .
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. A single float randomly sampled from the distribution is returned if no argument is provided.
Parameters : d0, d1, …, dn int, optional
The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
Returns : Z ndarray or float
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.
Similar, but takes a tuple as its argument.
Also accepts mu and sigma arguments.
which should be used for new code.
For random samples from the normal distribution with mean mu and standard deviation sigma , use:
sigma * np.random.randn(. ) + mu
>>> np.random.randn() 2.1923875335537315 # random
Two-by-four array of samples from the normal distribution with mean 3 and standard deviation 2.5:
>>> 3 + 2.5 * np.random.randn(2, 4) array([[-4.49401501, 4.00950034, -1.81814867, 7.29718677], # random [ 0.39924804, 4.68456316, 4.99394529, 4.84057254]]) # random
numpy.random.randn#
Return a sample (or samples) from the “standard normal” distribution.
This is a convenience function for users porting code from Matlab, and wraps standard_normal . That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones .
New code should use the standard_normal method of a Generator instance instead; please see the Quick Start .
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. A single float randomly sampled from the distribution is returned if no argument is provided.
Parameters : d0, d1, …, dn int, optional
The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
Returns : Z ndarray or float
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.
Similar, but takes a tuple as its argument.
Also accepts mu and sigma arguments.
which should be used for new code.
For random samples from the normal distribution with mean mu and standard deviation sigma , use:
sigma * np.random.randn(. ) + mu
>>> np.random.randn() 2.1923875335537315 # random
Two-by-four array of samples from the normal distribution with mean 3 and standard deviation 2.5:
>>> 3 + 2.5 * np.random.randn(2, 4) array([[-4.49401501, 4.00950034, -1.81814867, 7.29718677], # random [ 0.39924804, 4.68456316, 4.99394529, 4.84057254]]) # random
numpy.random.RandomState.randn#
Return a sample (or samples) from the “standard normal” distribution.
This is a convenience function for users porting code from Matlab, and wraps standard_normal . That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones .
New code should use the standard_normal method of a Generator instance instead; please see the Quick Start .
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. A single float randomly sampled from the distribution is returned if no argument is provided.
Parameters : d0, d1, …, dn int, optional
The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
Returns : Z ndarray or float
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.
Similar, but takes a tuple as its argument.
Also accepts mu and sigma arguments.
which should be used for new code.
For random samples from the normal distribution with mean mu and standard deviation sigma , use:
sigma * np.random.randn(. ) + mu
>>> np.random.randn() 2.1923875335537315 # random
Two-by-four array of samples from the normal distribution with mean 3 and standard deviation 2.5:
>>> 3 + 2.5 * np.random.randn(2, 4) array([[-4.49401501, 4.00950034, -1.81814867, 7.29718677], # random [ 0.39924804, 4.68456316, 4.99394529, 4.84057254]]) # random