Other Common Random Distributions in Python
📊 Other Common Random Distributions in Python
After Normal (Gaussian) distribution, NumPy can generate other statistical distributions like Uniform, Binomial, Poisson, and Exponential. Let’s go through each with examples and visualization.
1️⃣ Uniform Distribution
Generates numbers evenly distributed between low and high.
-
Values are equally likely between 0 and 10
-
kde=Trueshows the smooth density curve
2️⃣ Binomial Distribution
Simulates success/failure experiments, e.g., coin flips.
-
Peaks around
n*p(expected value) -
Discrete distribution
3️⃣ Poisson Distribution
Models count of events in a fixed interval.
-
Values are integers (0,1,2…)
-
Mean ≈ λ
4️⃣ Exponential Distribution
Models time between events, continuous.
-
Values ≥ 0
-
Skewed distribution, decays exponentially
5️⃣ Multinomial Distribution
Used for categorical outcomes with probabilities.
Output (example):
-
Each row = number of outcomes per trial
-
Each column = category
🧠 Summary Table of Distributions
| Distribution | Function | Key Parameters | Type |
|---|---|---|---|
| Normal | np.random.normal() |
loc, scale, size | Continuous |
| Uniform | np.random.uniform() |
low, high, size | Continuous |
| Binomial | np.random.binomial() |
n, p, size | Discrete |
| Poisson | np.random.poisson() |
lam, size | Discrete |
| Exponential | np.random.exponential() |
scale, size | Continuous |
| Multinomial | np.random.multinomial() |
n, pvals, size | Discrete |
🎯 Practice Exercises
-
Generate 5000 numbers from uniform distribution (0–100) and plot histogram.
-
Simulate 100 coin flips with probability 0.3 and plot frequency of heads.
-
Generate Poisson data with λ=7 and visualize it.
-
Generate exponential data with scale=3 and plot histogram + KDE.
