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

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.

### Related Resources:

- Create array with Random numbers | Numpy tutorial Create array with Random Numbers Create array with Random Numbers with random module of Numpy library. In this Numpy tutorial...
- Learn Numpy with mini tutorials Numpy Learn Numpy with easy mini tutorials. Numpy is a scientific computing package. Numpy operations are highly optimized therefore handling...
- Numpy Arange Create an Array | Numpy tutorial Numpy Arange Use numpy arange method to create array with sequence of numbers. In the below example we create an...
- Feature Selection and Dimensionality Reduction | The Ultimate Guide Feature Selection and Dimensionality Reduction Feature selection and Dimensionality Reduction methods are used for reducing the number of features in...
- Rank of a Matrix | Numpy tutorial Rank of a Matrix Find Rank of a Matrix using “matrix_rank” method of “linalg” module of numpy. Rank of a...
- Reshape Numpy array | Numpy Tutorial Reshape Numpy Array Reshape numpy array with “reshape” method of numpy library. Reshaping numpy array is useful to convert array...
- Read csv file to numpy array Read csv file to numpy array Use “savetxt” method of numpy to save a numpy array to csv file Use...
- The No 1 Ultimate Guide to Comments and Docstrings in Python The Ultimate Guide to Comments and Docstrings in Python In this, Comments and docstrings in python tutorial we will be...
- Digits Dataset | Scikit learn datasets Digits Dataset Digits Dataset is a part of sklearn library. Sklearn comes loaded with datasets to practice machine learning techniques...
- Trace of Matrix in Python | Numpy Tutorial Trace of Matrix Trace of Matrix is the sum of main diagonal elements of the matrix. Main Diagonal also known...

Thanks

i learned and enjoyed

Wonderful article.

Like!! Thank you for publishing this awesome article.