Normal Distribution is a probability distribution where probability of x is highest at centre and lowest in the ends whereas in Uniform Distribution probability of x is constant.

Normal vs Uniform distribution

Normal Distribution is a probability distribution which peaks out in the middle and gradually decreases towards both ends of axis.  It is also known as gaussian distribution and bell curve because of its bell like shape. Formula for normal probability distribution is as follows, where  \(\mu\) is mean and \(\sigma^2\) is variance.

Normal Distribution formula

Uniform Distribution is a probability distribution where probability of x is constant. That is to say, all points in range are equally likely to occur consequently it looks like a rectangle. Formula for Uniform probability distribution is f(x) = 1/(b-a), where range of distribution is [a, b].

Below we have plotted 1 million normal random numbers and  uniform random numbers. .

Author: Ankit (thatascience)

Last Modified: 14 June, 2020

Code to generate and plot Normal Distribution Vs Uniform distribution

# Imports
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
import warnings
warnings.simplefilter("ignore", UserWarning)

# Let's create an array of random numbers from uniform distribution
uniform = np.random.uniform(-4,4,1000000)

# Let's create an array of random numbers from normal distribution
normal = np.random.randn(1000000)

# Let's plot them
ax = sns.distplot(uniform, label='Uniform Distribution')
bx = sns.distplot(normal, label= 'Normal Distribution')
legend = plt.legend()
plt.show()
 

To Conclude - That's Normal Distribution Vs Uniform Distribution

That’s all for this mini tutorial. To sum it up, we learned the difference between normal distribution and uniform distribution. Further, we learned how to generate and plot the distributions using numpy and seaborn respectively. 

Hope it was easy, cool and simple to follow. Now it’s on you.

3 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *