لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him. # Python Data Science NumPy Random Uniform Data Distribution Generating Random Numbers

Uniform Distribution: An event where all events have equal chance of occurence is known as uniform distribution.

E.g. Generation of random numbers.

It has three parameters.

1. a - lower bound - default 0 .0.

2. b - upper bound - default 1.0.

3. size - The shape of the returned array.

Example 1: Create a 2x4 uniform distribution sample.

Code

from numpy import random

x = random.uniform(size=(2, 4))

print (x)

the output will be

[[0.50164709 0.50358835 0.31553559 0.68727814]

[0.34223024 0.30040926 0.34707715 0.22671552]]

Note: Every time the code is run the output may differ because of random generation

Visualization of Uniform Distribution

Example 2

Code

from numpy import random
import matplotlib.pyplot as plt
import seaborn as sns

sns.distplot(random.
uniform(size=3000000), hist=False)

plt.show()

the output will be Note: As visible from the plot we get an almost straight line indicating that all events have equal chances of occurence.