Curriculum
Course: NumPy
Login

Curriculum

NumPy

Text lesson

Uniform Distribution

Uniform distribution describes probabilities where all events have an equal chance of occurring, such as in random number generation.

It has three parameters:

  • a: Lower bound (default 0.0).
  • b: Upper bound (default 1.0).
  • size: Shape of the resulting array.

Example

Generate a 2×3 sample from a uniform distribution:

from numpy import random

x = random.uniform(size=(23))

print(x)

Visualization of Uniform Distribution

Example

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

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

plt.show()

Result

uniform1