codingstreets
Search
Close this search box.
python-normal- distribution

Introduction to Python Normal Distribution

In This Article, You Will Learn About Python Normal Distribution.

Python Normal Distribution – Before moving ahead, let’s know a bit of Python Visualize Distributions with Seaborn

It is called the Gaussian Distribution and known one of the most important distributions.

It is knowing best to work with probability distribution such as IQ Scores, Heartbeat etc.

To get a Normal Data Distribution, use the random.normal() method.

It contains three parameters.

loc – It specifies the mean
scale - It specifies the Standard Deviation
size – It specifies the shape of the array in terms of Row and Column.

Apart from above all, there is an additional parameter –

hist – It is Histogram (full form) that put a group of numbers together between the range.

Example – Creating a random normal distribution array of size 3×2.

from numpy import random

x = random.normal(size=(3, 2))

print(x)
python-normal-distribution

As a result, it returned shape of 3×2 array of random float numbers.  

Example – Creating a random normal distribution of size 3×2 with mean at 1 and standard deviation of 2.

from numpy import random

x = random.normal(loc=8, scale=12, size=(3, 2))

print(x)
Output - 

[[24.58910238  7.91364785]
  [-5.28282301 10.04603531]
   [20.49968082  7.87460784]]

As a result, it returned shape of 3×2 array of random float numbers.  

Visualization of Normal Distribution

Example – Generating an Array with different random numbers.  

from numpy import random
import matplotlib.pyplot as plt
import seaborn as kl

kl.distplot(random.normal(size=5000))

plt.show()
python-normal-distribution

As can be seen, it returned a graph plotted with different points on different location.

Example – Generating an Array with different random numbers.  

from numpy import random
import matplotlib.pyplot as plt
import seaborn as kl

kl.distplot(random.normal(size=5000), hist=False)

plt.show()
python-normal-distribution

As shown above, it returned a graph plotted with different points on different location.

Note: Normal Distribution is also known as the Bell Curve because it is shaped like Bell curve.

If you find anything incorrect in the above-discussed topic and have any further questions, please comment below.

Like us on

Recent Post

Popular Post

Top Articles

Archives
Categories

Share on