GENERATE RANDOM NUMBERS: NUMPY BASIC EXERCISE 18


Find a solution in Numpy that generate random numbers based on standard normal distribution

In this exercise, we are going to generate random number up-to 20 based on standard normal distribution.

Note: normal(loc=0.0, scale=1.0, size=None). Draw random samples from a normal (Gaussian) distribution. The probability density function of the normal distribution, first derived by De Moivre and 200 years later by both Gauss and Laplace independently.

Code

import numpy as np
rand = np.random.normal(0,20,20)
print("Generating 20 random values")
print(rand)

Output

Generating 20 random values
[-41.04710687 -13.95470119 -15.01538703 -33.57800168  12.98236712
 -16.12801452   6.9631557   11.87425154  25.69415256  30.71314733
   7.43508363  31.18996274  18.33545056   9.82372055 -12.38501579
 -21.00535824 -44.48524337  -1.5283168   10.12943489 -25.7899703 ]

Code Editor

import numpy as np rand = np.random.normal(0,20,20) print("Generating 20 random values") print(rand)

References:
StatTrek: Statistics Dictionary