# What is the numpy.random.normal() Method

The numpy.random.normal() function generates random values from a normal (Gaussian) distribution. The normal distribution is often called the bell curve because of its shape. As the shape of the normal distribution graph looks like the bell, it is often called the bell curve.

### Syntax

``random.normal(loc = 0.0, scale =1.0, size = None)``

### Arguments

loc: It is also called the Mean. It is the mean of the normal distribution. The mean is the average of the normal distribution. If nothing is passed in the argument, it automatically assumes 0.0 as the mean for the normal distribution. Because if the normal distribution is obtained, then the mean is 0; hence 0.0 is assigned by default.

scale: It is also called the standard deviation. It is the standard deviation of the normal distribution. As the name suggests,s it is the standard deviation between the points in the normal distribution. If the standard deviation is passed as the argument, the function automatically assigns the value 1.0.

size: It is the number of samples to be drawn. If n is the number of samples passed in the argument, then n samples are drawn. If nothing is given in the argument then 1 sample will be drawn.

### Example 1

``````import numpy as np

normal_dist = np.random.normal()
print(normal_dist)``````

Output

``3.5463349551368286``

In this program, we imported a numpy package consisting of several functions. We used a function called random.normal(). This is the function present inside the random class of the numpy package. The np.random.normal() function finds the normal distribution for the random samples.

### Example 2

``````import numpy as np

# creating a variable for storing mean
mu = 1.0

# creating a variable for storing standard deviation
sigma = 2.5

# creating a variable for storing the number of samples
siz = 7
normal_dist = np.random.normal(mu, sigma, siz)
print(normal_dist)
``````

Output

``````[-1.58196785 0.29736585 1.81180083 4.33999648
5.55233104 2.37637558 -1.43250784]``````

In this program, we created three variables: mu, sigma, and siz.

The mu is used for storing the mean of the normal distribution. Sigma is used for storing the standard deviation. And the siz is used for storing the number of samples.

We passed the mean, standard deviation, and size to the function. Hence, the output will have seven samples as we have given seven as the size.

That’s it.

This site uses Akismet to reduce spam. Learn how your comment data is processed.