Different Types of Distributions
In this tutorial, we are going to learn about some of the important probability distributions
Normal (Gaussian) Distribution
- It is one of the most important distribution.
- It is named after German mathematician Carl Friedrich Gauss.
- Normal Distribution represents the probability distribution of many events like IQ Scores, Heartbeat, SAT scores, etc.
- In this, we use randint.normal() to get the normal distribution.
- There are 3 parameters:
-
loc - (Mean) the location of the bell's peak.
-
scale - (Standard Deviation) the degree to which the graph distribution should be flat.
-
size - The returned array's shape.
-
-
For Example: Generating normal distribution of 1 row and 3 columns:
from numpy import random x = random.normal(size=(1, 3)) print(x) # [[-1.63425818 -0.72404996 -1.00067313]]
- Example: Generate a random normal distribution of size 2x3 with a mean at 2 and a standard deviation of 3:
from numpy import random x = random.normal(loc=2, scale=3, size=(2, 3)) print(x) # [[-0.15130504 7.52009596 1.85673872] # [ 2.329166 1.39781714 -3.99898674]]
Binomial Distribution
- It is a Discrete Distribution i.e. separate set of events.
- The outcome in this distribution is binary for instance toss of a coin either head or tail.
- It has three parameters:
-
n
- the number of trials. -
p
- the probability of occurrence of each trial (e.g. for the toss of a coin 0.5 each). -
size
- The shape of the returned array.
-
-
For example: for 15 trials in a coin toss generate 20 data points:
from numpy import random x = random.binomial(n=15, p=0.5, size=20) print(x) # [ 6 7 9 6 6 7 7 7 7 6 9 8 9 8 7 10 7 8 8 9]
Poisson Distribution
- It is also a Discrete Distribution.
- It calculates how many times an event can occur in a given amount of time. For example, if someone plays twice a day, what is the likelihood that he will play again for the third time.
- It has 2 parameters:
-
lam - rate or known number of occurrences.
-
size - The shape of the returned array.
-
-
For example: Generating a random distribution for the occurrence of 4:
from numpy import random x = random.poisson(lam=4, size=15) print(x) # [2 5 3 2 5 1 4 3 3 7 4 2 5 6 1]