# Normal Distribution Vs Uniform Distribution

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 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.

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)

## 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

1. Anonymous says:

Thanks
i learned and enjoyed

2. Mari says:

Wonderful article.

3. ปั้มไลค์ says:

Like!! Thank you for publishing this awesome article.