LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.
Python Data Science Numpy Random Normal Data Distribution Or Gaussian Distribution
Normal Data Distribution: is one of the most important distributions. It is also called the Gaussian Distribution after the German mathematician Carl Friedrich Gauss.
Normal Data Distribution fits the probability distribution of many events, eg. IQ Scores,
Heartbeat etc. It uses the random.normal() method to get a Normal Data Distribution.
It has following three parameters.
1. loc - (Mean) where the peak of the bell exists.
2. scale - (Standard Deviation) how flat the graph distribution should be.
3. size - The shape of the returned array.
Example 1: Generate a random normal distribution of size 2x4.
Code
from numpy import random
x = random.normal(size=(2, 4))
print(x)
the output will be
[[-0.33506496 -0.31473452 -0.30287562 -0.29819583]
[ 0.71113016 0.03042099 0.54483415 -1.69259665]]
Note: The output may differ everytime the code is run as it is generated at random.
Example 2: Generate a random normal distribution of size 2x4 with mean at 1 and standard deviation of 2.
Code
from numpy import random
x = random.normal(loc=1, scale=2, size=(2, 4))
print(x)
the output will be
[[ 0.44950309 1.25483979 -0.25427951 0.94383889]
[ 2.47519924 2.66471074 -0.136005 -2.06265979]]
Note: The output may differ everytime the code is run as it is generated at random.
Visualization of Normal Distribution Without Histogram
Example 3
from numpy import random
import matplotlib.pyplot as plt
import seaborn as sns
sns.distplot(random.
normal(size=100000),
hist=False)
plt.show()
the output will be
Note: The curve of a Normal Distribution is also known as the Bell Curve because
of the bell-shaped curve.
Visualization of Normal Distribution With Histogram
Example 4
Code
from numpy import random
import matplotlib.pyplot as plt
import seaborn as sns
sns.distplot(random.
normal(size=100000))
plt.show()
the output will be
Note: The curve of a Normal Distribution is also known as the Bell Curve because
of the bell-shaped curve.