The Normal Distribution is one of the most significant distributions and is also known as the Gaussian Distribution, named after the German mathematician Carl Friedrich Gauss. It accurately represents the probability distribution of various events, such as IQ scores and heartbeats. You can obtain a Normal Data Distribution using the random.normal() method.
It has three parameters:
loc: Represents the mean, indicating where the peak of the bell curve is located.
scale: Denotes the standard deviation, determining the flatness of the distribution’s graph.
size: Defines the shape of the resulting array.
Create a random normal distribution with a size of 2×3:
from numpy import random x = random.normal(size=(2, 3)) print(x) |
Create a random normal distribution of size 2×3 with a mean of 1 and a standard deviation of 2:
from numpy import random x = random.normal(loc=1, scale=2, size=(2, 3)) print(x) |
from numpy import random import matplotlib.pyplot as plt import seaborn as sns sns.distplot(random.normal(size=1000), hist=False) plt.show() |
Note: The curve of a Normal Distribution is referred to as the Bell Curve due to its bell-shaped appearance. |