Understanding Probability Distributions
Understanding Probability Distributions
Example
Consider a spam detection model where A is the event ”email
contains the word ’free’” and B is the event ”email is spam”.
Understanding P(B | A) helps in improving the accuracy of the
model.
Random Variables
Example
In a recommendation system, let X be a discrete random variable
representing the number of clicks on recommended items. A
continuous random variable Y might represent the time a user
spends on a page.
Mathematical Expectation (Expected Value)
▶ The Expected Value or Expectation of a random variable is
the long-run average value of repetitions of the experiment it
represents.
▶ For a discrete random variable X with PMF P(X = xi ) = pi ,
the expectation is:
X
E [X ] = xi · pi
i
Example
In an e-commerce setting, X could represent the revenue generated
per user. The expected revenue, E [X ], is a crucial metric for
decision-making.
Mean
▶ The Mean of a random variable is another term for its
expected value and provides a measure of the central
tendency of the distribution.
▶ For a discrete random variable X :
X
µ = E [X ] = x i · pi
i
Example
In a user engagement model, the mean number of interactions per
session can inform interface design and content placement.
Variance
▶ The Variance of a random variable is a measure of how much
the values of the random variable differ from the mean.
▶ For a discrete random variable X :
X
Var(X ) = E [(X − µ)2 ] = (xi − µ)2 · pi
i
5. Variance(σ 2 ):
n
X
σ2 = xi2 P(xi ) − µ2 or σ 2 = E [X 2 ] − (E [X ])2
i=1
Probability Density Function (PDF)
The Probability Density Function (PDF) is the probability
distribution of a continuous random variable and provides the
possible values and their associated probabilities infinitely.
1. P(xi ) ≥ 0 or f (x) ≥ 0
R∞
2. −∞ f (x) dx = 1
3. Mean (µ): Z ∞
µ= xf (x) dx
−∞
4. Variance (σ 2 ):
Z ∞
2
σ = x 2 f (x) dx − µ2
−∞
σ 2 = E [X 2 ] − (E [X ])2
First, find E [X 2 ]:
X
E [X 2 ] = x 2 · P(x)
x
Calculating E [X 2 ]:
1 3 3 1
E [X 2 ] = 02 · + 12 · + 2 2 · + 32 ·
8 8 8 8
3 12 9 24
E [X 2 ] = 0 + + + = =3
8 8 8 8
Now, calculate the variance:
x -3 -2 -1 0 1 2 3
P(x) k 2k 3k 4k 3k 2k k
Solution:
The sum of all probabilities must equal 1 for it to be a valid
probability distribution:
k + 2k + 3k + 4k + 3k + 2k + k = 1
16k = 1
1
k=
16
The mean µ is given by:
X
µ = E [X ] = xi · P(xi )
i
σ 2 = E [X 2 ] − (E [X ])2
First, compute E [X 2 ]:
X
E [X 2 ] = xi2 · P(xi )
i
1 2 3
E [X 2 ] = (−3)2 · + (−2)2 · + (−1)2 · + 02
16 16 16
4 3 2 1
· + 12 · + 22 · + 32 ·
16 16 16 16
9 + 8 + 3 + 0 + 3 + 8 + 9 40
E [X 2 ] = = = 2.5
16 16
Since µ = 0:
σ 2 = 2.5 − 02 = 2.5
√
σ = 2.5 ≈ 1.58
P(x ≤ 1) = P(−3) + P(−2) + P(−1) + P(0) + P(1)
1 13
∴ P(x ≤ 1) = k + 2k + 3k + 4k + 3k = 13k = 13 × =
16 16
1 3
P(x > 1) = P(2) + P(3) = 2k + k = 3k = 3 × =
16 16
1 9
= P(0) + P(1) + P(2) = 4k + 3k + 2k = 9k = 9 × =
16 16
Problem 3
x 0 1 2 3 4 5 6 7
P(x) 0 k 2k 2k 3k k2 2k2 7k2+k
Find:
(i) k
(ii) P(x < 6)
(iii) P(x ≥ 6)
(iv) P(3 < x ≤ 6)
Solution: To find the value of k, we use the fact that the total
probability must equal 1:
0 + k + 2k + 2k + 3k + k 2 + 2k 2 + (7k 2 + k) = 1
Simplifying this, we have:
10k + 10k 2 − k = 1
This simplifies to:
10k 2 + 9k − 1 = 0
√
2
b −4ac
Using the quadratic formula k = −b± 2a , where a = 10,
b = 9, and c = −1, we find:
p √
−9 ± 92 − 4 · 10 · (−1) −9 ± 81 + 40
k= =
2 · 10 20
√
−9 ± 121
k=
20
−9 ± 11
k=
20
So, the two possible values for k are:
1
k= = 0.1(we have k = -1 also, but k must be positive)
10
Now, calculate the probabilities:
ii) P(x < 6) = P(0) + P(1) + P(2) + P(3) + P(4) + P(5) =
0 + k + 2k + 2k + 3k + k 2 = 8k + k 2
iii) P(x ≥ 6) = P(6) + P(7) = 2k 2 + (7k 2 + k) = 9k 2 + k
iv) P(3 < x ≤ 6) = P(4)+P(5)+P(6) = 3k +k 2 +2k 2 = 3k +3k 2
Using k = 0.1:
Solution:
To show that f (x) is a probability density function, it must satisfy
two conditions:
1. f (x) ≥ 0 for all x.
2. The total integral of f (x) over all x must equal 1.
(i). Non-negativity:
= −e −2.5 + e −1.5
= e −1.5 − e −2.5
1 1
= −
e 1.5 e 2.5
Thus,
1 1
P(1.5 < x < 2.5) = −
e 1.5 e 2.5
Problem 5
3 3
x3
Z
27
∴k x 2 dx = k =k −0 = 9k
0 3 0 3
So,
1
9k = 1 =⇒ k =
9
ii) P(x ≤ 1):
Z 1 Z 1
1 2
P(x ≤ 1) = f (x) dx = x dx
0 0 9
1
1 x3 1 1 1
∴ = · =
9 3 0 9 3 27
iii) P(x > 1):
1 26
P(x > 1) = 1 − P(x ≤ 1) = 1 − =
27 27
iv) P(1 ≤ x ≤ 2):
Z 2 Z 2
1 2
P(1 ≤ x ≤ 2) = f (x) dx = x dx
1 1 9
3 2
1 x 1 8 1 1 7 7
∴ = − = · =
9 3 1 9 3 3 9 3 27
v) P(x ≤ 2):
Z 2 Z 2
1 2
P(x ≤ 2) = f (x) dx = x dx
0 0 9
3 2
1 x 1 8 8
∴ = · =
9 3 0 9 3 27
vi) P(x ≥ 2):
8 19
P(x ≥ 2) = 1 − P(x ≤ 2) = 1 − =
27 27
Problem 6
The diameter of an electric cable is assumed to be a continuous
random variable with a probability density function (PDF) given by:
(
kx(1 − x), 0 ≤ x ≤ 1
f (x) =
0, otherwise
Find:
(i) The value of k.
(ii) The Mean and Variance.
Solution:
The total probability must be equal to 1:
Z ∞ Z 1
f (x) dx = kx(1 − x) dx = 1
−∞ 0
Z 1 Z 1 Z 1
2
∴k x(1 − x) dx = k x dx − x dx
0 0 0
1 1 !
x2 x3
1 1
k − =k −
2 0 3 0 2 3
3 2 1
k − =k
6 6 6
k
= 1 =⇒ k = 6
6
The mean µ is given by:
Z ∞ Z 1
µ = E [X ] = xf (x) dx = x · 6x(1 − x) dx
−∞ 0
Z 1 Z 1 Z 1
2 2 3
∴6 x (1 − x) dx = 6 x dx − x dx
0 0 0
1 !
1
x4
x3
1 1
6 − =6 −
0 34 0 3 4
4 3 1 6 1
6 − =6 = =
12 12 12 12 2
Thus, the mean µ = 12 .
The variance σ 2 is given by:
σ 2 = E [X 2 ] − (E [X ])2
Z ∞ Z 1
E [X 2 ] = x 2 f (x) dx = x 2 · 6x(1 − x) dx
−∞ 0
Z 1 Z 1 Z 1
3 3 4
6 x (1 − x) dx = 6 x dx − x dx
0 0 0
1 !
1
x4x5
1 1
6 − =6 −
0 4 5 0 4 5
5 4 1 6 3
6 − =6 = =
20 20 20 20 10
3
So, E [X 2 ] = 10 .
2
2 3 1 3 1 3 2.5 0.5 1
σ = − = − = − = =
10 2 10 4 10 10 10 20
1
Thus, the variance σ 2 = 20 .
Assignment Problems (DRV)
1. Find the value of k such that the following distribution
represents a discrete probability distribution. Hence, find the
Mean, S.D, P(x ≥ 5), and P(3 < x ≤ 6). [Ans: (i) k=1/49,
Mean = 4.14, S.D = 1.64, (ii) 0.48 (iii) 0.67]
x 0 1 2 3 4 5 6
P(x) k 3k 5k 7k 9k 11k 13k
2. A random variable has the following probability function for
the various values of X = x. Find i) the value of k, ii)
P(x < 1), iii) P(x ≥ 1). [Ans: (i) k=0.1 (ii) 0.4 (iii) 0.9]
x -2 -1 0 1 2 3
P(x) 0.1 k 0.2 2k 0.3 k
3. A random variable has the following probability function for
the various values of X = x. Find i) the value of k, ii)
P(x ≤ 1), iii) P(0 ≤ x < 3). [Ans: (i) k=1/32 (ii) 0.18 (iii)
0.5]
x 0 1 2 3 4 5
P(x) k 5k 10k 10k 5k k
Assignment Problems (CRV)
1. A random variable X has the probability density function
(PDF):
(
kx 2 , −3 ≤ x ≤ 3
f (x) =
0, otherwise
Find:
i) k [Ans:1/18]
ii) P(x ≤ 2) [Ans:35/54]
iii) P(x ≥ 2) [Ans:19/54]
iv) P(x > 1) [Ans:26/54]
v) P(1 ≤ x ≤ 2) [Ans:7/54]
2. Find the constant k such that
(
kxe −x , 0 < x < 1
f (x) =
0, otherwise
is a valid probability density function (PDF). Find the mean.
[Ans: (i)k=e/(e-2) (ii)=(2e-5)/(e-2)]
Module I: Probability Distributions
Topic 2: Binomial Distribution
Example
In a binary classification problem, the Binomial Distribution can
model the number of correct predictions (successes) out of n total
predictions made by a machine learning model.
Binomial Distribution(Continued..)
Let X be a discrete random variable, p be the probability of
success, and q be the probability of failure. The probability mass
function of the binomial distribution can be defined as:
(
n x n−x
x p q , x ≥0
P(X = x) = b(n, p, x) =
0, Otherwise
where n is the number of trials and n p are the parameters.
where q = 1 − p.
The mean (expected value) µX of X is defined as:
n
X
µX = E (X ) = x · P(X = x)
x=0
Since p + q = 1, we have: µX = np
To find the variance, we first calculate E (X (X − 1)):
n
X
E (X (X − 1)) = x(x − 1) · P(X = x)
x=0
Substituting the PMF:
n
X n x n−x
E (X (X − 1)) = x(x − 1) p q
x
x=0
This can be simplified as:
n
X n − 2 x−2 (n−2)−(x−2)
2
E (X (X − 1)) = n(n − 1)p p q
x −2
x=2
Letting y = x − 2, the sum becomes:
n−2
2
X n − 2 y (n−2)−y
E (X (X −1)) = n(n−1)p p q = n(n−1)p 2 (p+q)n−2
y
y =0
Since p + q = 1, we have:
E (X (X − 1)) = n(n − 1)p 2
The variance σX2 of X is given by:
σX2 = E (X 2 ) − (E (X ))2
Expanding E (X 2 ):
E (X 2 ) = E (X (X − 1)) + E (X )
Substituting the values:
σX2 = n(n − 1)p 2 + np − (np)2
Simplifying:
σX2 = np(1 − p) = npq
σX2 = npq.
Standard Deviation of the Binomial Distribution
The standard deviation σX is the square root of the variance:
√
σX = npq
Thus, the standard deviation of the binomial distribution is
√
σX = npq.
Problem 1
P(X = 1) = 0.3766
P(X = 0) ≈ 0.3487
(ii). Probability that all lines are busy (P(X = 10))
10
P(X = 10) = (0.1)10 (0.9)0
10
Calculate P(X = 10):
P(X ≥ 1) = 1 − P(X = 0)
Using the value of P(X = 0) calculated earlier:
Example
The Poisson Distribution can model the number of user clicks on a
webpage per minute or the number of requests to a server per hour.
Poisson Distribution (Continued..)
▶ The probability mass function (PMF) of the Poisson
Distribution is given by:
λk e −λ
P(X = k) =
k!
▶ Here:
▶ X is the random variable representing the number of events.
▶ k is the actual number of events that occur.
▶ λ is the average rate (mean number of events in the interval).
▶ e is the base of the natural logarithm (approximately 2.71828).
▶ The PMF gives the probability of observing exactly k events
in a fixed interval.
Example
Suppose a server receives an average of 5 requests per minute.
The Poisson Distribution can be used to find the probability that
the server receives exactly 8 requests in a given minute.
Poisson Distribution (Continued..)
Let X be the discrete random variable for any real value λ, such
that the probability mass function of the Poisson distribution can
be defined as:
( −λ x
e λ
P(X = x) = P(x) = x! , x ≥ 0
0, otherwise
where λ is called the parameter.
i) P(X = x) = P(x) ≥ 0
P∞ P∞ e −λ λx
ii) x=0 P(x) = x=0 x! =1
iii) Mean, µ = np = λ
√
iv) Variance, σ 2 = λ, S.D = λ
Relationship to Other Distributions
Example
If a machine learning model is evaluated over a large dataset with
rare events (such as detecting rare failures), the distribution of the
number of detected failures might be approximated by a Poisson
Distribution.
Applications in AI and Data Science
e −λ λx
P(X = x) = , x = 0, 1, 2, . . .
x!
1. Mean of a Poisson Distribution
The mean (expected value) E (X ) of a Poisson distribution can be
derived as follows:
∞ ∞
X X e −λ λx
E (X ) = x · P(X = x) = x·
x!
x=0 x=0
λx
Rewriting x as x = x · x(x−1)! , we have:
∞
X λx
E (X ) = e −λ
(x − 1)!
x=1
Let y = x − 1, then x = y + 1 and as x goes from 1 to ∞, y goes
from 0 to ∞:
∞
X λy
E (X ) = e −λ λ
y!
y =0
P∞ λy
Using the fact that y =0 y ! = e λ , we get:
E (X ) = e −λ λe λ = λ
Therefore, the mean of a Poisson distribution is:
E (X ) = λ
2. Variance of a Poisson Distribution
The variance Var(X ) of a Poisson distribution is given by
E (X 2 ) − [E (X )]2 .
First, we find E (X 2 ):
∞ ∞
X X e −λ λx
E (X 2 ) = x 2 · P(X = x) = x2 ·
x!
x=0 x=0
Rewriting x 2 as x(x − 1) + x, we have:
∞ ∞
−λ
X λx X λx−1
2
E (X ) = e + e −λ λ
(x − 2)! (x − 1)!
x=2 x=1
E (X 2 ) = λ2 + λ
Then, the variance is:
Var(X ) = λ
Problem 1
Solution:
Given that X follows a Poisson distribution with mean λ = 3.
e −λ λx
P(X = x) =
x!
where λ = 3.
(i) Number of drivers with no accident in a year:
e −3 · 30
P(X = 0) = = e −3 ≈ 0.0498
0!
The expected number of drivers with no accidents is:
Solution:
Let X denote the number of defective blades in a packet. The
1
probability of a blade being defective is p = 500 . The mean
number of defective blades per packet, λ, can be calculated as:
1 10
λ = np = 10 × = = 0.02
500 500
The Poisson probability mass function is given by:
e −λ λx
P(X = x) =
x!
where λ = 0.02.
e −0.02 · 0.020
P(X = 0) = = e −0.02 ≈ 0.9802
0!
The expected number of packets with no defective blades is:
e −0.02 · 0.022
P(X = 2) =
2!
e −0.02 · 0.0004 0.9802 × 0.0004
= ≈ = 0.000196
2 2
The expected number of packets with 2 defective blades is:
e −0.02 · 0.023
P(X = 3) =
3!
e −0.02 · 0.000008 0.9802 × 0.000008
= ≈ = 0.00000131
6 6
The expected number of packets with 3 defective blades is:
Solution:
Let X denote the number of individuals who get a bad reaction.
The probability of a bad reaction for an individual is p = 0.001.
For 2000 individuals, we have n = 2000.
The mean number of bad reactions, λ, is given by:
λ = np = 2000 × 0.001 = 2
Since n is large and p is small, we can use the Poisson
approximation to the binomial distribution, where X ∼ Poisson(λ).
The probability mass function of a Poisson distribution is:
e −λ λx
P(X = x) =
x!
where λ = 2.
To find the probability that more than 2 individuals will get a bad
reaction, we need to calculate P(X > 2):
e −2 · 20
P(X = 0) = = e −2 ≈ 0.1353
0!
e −2 · 21
P(X = 1) = = 2e −2 ≈ 0.2707
1!
e −2 · 22
P(X = 2) = = 2e −2 ≈ 0.2707
2!
Summing these probabilities:
Example
In AI, the Normal Distribution can model the distribution of errors
in predictions made by regression models, or the distribution of
features in a dataset for a machine learning algorithm.
Probability Density Function (PDF)
▶ The probability density function (PDF) of the Normal
Distribution is given by:
(x − µ)2
1
f (x) = √ exp −
2πσ 2 2σ 2
▶ Here:
▶ x is the variable.
▶ µ is the mean of the distribution.
▶ σ 2 is the variance of the distribution.
▶ exp is the exponential function.
▶ The PDF describes the likelihood of a random variable taking
on a particular value.
Example
In a machine learning context, the PDF can describe the
distribution of continuous features in a dataset. For instance, if we
assume that the heights of people in a dataset follow a Normal
Distribution, the PDF can tell us the likelihood of finding someone
with a specific height.
Properties of the Normal Distribution
▶ Symmetry: The Normal Distribution is symmetric around the
mean µ.
▶ Mean, Median, and Mode: For a Normal Distribution, the
mean, median, and mode are all equal.
▶ 68-95-99.7 Rule (Empirical Rule):
▶ Approximately 68% of the data lies within one standard
deviation (σ) of the mean.
▶ Approximately 95% of the data lies within two standard
deviations of the mean.
▶ Approximately 99.7% of the data lies within three standard
deviations of the mean.
▶ Unimodal: The distribution has a single peak (mode) at the
mean µ.
Example
When evaluating model performance, the errors or residuals (the
differences between observed and predicted values) are often
assumed to follow a Normal Distribution. This assumption
underlies many statistical tests and confidence intervals.
Standard Normal Distribution
▶ The Standard Normal Distribution is a special case of the
Normal Distribution with a mean of 0 and a standard
deviation of 1.
▶ Any Normal Distribution can be converted to the Standard
Normal Distribution using the z-score:
x −µ
z=
σ
▶ The z-score represents the number of standard deviations a
data point is from the mean.
Applications in AI and Data Science
Solution:
Given:
Mean (µ) = 30
Standard Deviation (σ) = 6.25
Total number of students = 200
P(X < 35) = P(Z < 0.8) = 0.5 + Z (0.8) = 0.5 + 0.2881 = 0.7881
Since the Z-table gives the area to the left of a given Z-value and
the normal distribution is symmetric:
The expected number of bulbs lasting more than 2100 hours is:
Solution:
Given:
P(X < 45) = 0.31
P(X > 64) = 0.08
Let the mean be µ and the standard deviation be σ. We need to
find the Z-scores corresponding to these probabilities.
Step 1: Finding Z-scores from the standard normal
distribution table.
−0.50σ = 45 − µ =⇒ µ = 45 + 0.50σ
From z2 :
1.41σ = 64 − µ
Substitute µ = 45 + 0.50σ into the second equation:
1.41σ + 0.50σ = 64 − 45
1.91σ = 19
19
σ= ≈ 9.95
1.91
Now, find µ:
Solution:
Given:
P(X < 35) = 0.07
P(X < 60) = 0.89
Let the mean be µ and the standard deviation be σ. We need to
find the Z-scores corresponding to these probabilities.
Step 1: Finding Z-scores from the standard normal
distribution table.
−1.48σ = 35 − µ =⇒ µ = 35 + 1.48σ
From z2 :
1.23σ = 60 − µ
Substitute µ = 35 + 1.48σ into the second equation:
1.23σ + 1.48σ = 60 − 35
2.71σ = 25
25
σ= ≈ 9.23
2.71
Now, find µ:
Example
The Exponential Distribution can model the time between user
clicks on a webpage or the time between requests to a server.
Probability Density Function (PDF)
1
Var(X ) =
α2
▶ These properties show that the mean time between events is
the reciprocal of the rate parameter α.
Example
If the average time between failures in a system is 2 hours, the
mean is 2 hours, and the variance is 4 hours squared. The rate
parameter α would be 1/2 = 0.5 failures per hour.
Applications in AI and Data Science
Solution:
Thus,
P(X > 1) = e −1/3 ≈ 0.7165
To find P(X < 3):
Z 3
1 −x/3
P(X < 3) = e dx
0 3
Thus,
P(X < 3) = 1 − e −1 ≈ 0.6321
Problem 2
Solution:
Thus,
P(X < 200) = 1 − e −1 ≈ 0.6321
(ii). Probability that the life is between 100 and 300 months:
Z 300
1 −x/200
P(100 < X < 300) = e dx
100 200
Calculating the integral:
h i300
P(100 < X < 300) = −e −x/200 = −e −1.5 − −e −0.5
100
Thus,
P(100 < X < 300) = e −0.5 − e −1.5 ≈ 0.3033
(iii). Probability that the life is more than 200 months:
Z ∞
1 −x/200
P(X > 200) = e dx
200 200
Calculating the integral:
h i∞
P(X > 200) = −e −x/200 = 0 − −e −1 = e −1
200
Thus,
P(X > 200) = e −1 ≈ 0.3679
Problem 3
The length of a telephone conversation is an exponential random
variable with a mean of 3 minutes. Find the probability that a call:
(i) Ends in less than 3 minutes
(ii) Ends between 3 and 5 minutes
(iii) Ends in more than 4 minutes
Solution:
The probability density function (pdf) of an exponential
distribution with mean µ = 3 minutes is given by:
1 −x/µ
f (x) = e , x ≥0
µ
For mean µ = 3, the pdf becomes:
1
f (x) = e −x/3
3
(i). Probability that the call ends in less than 3 minutes:
Z 3
1 −x/3
P(X < 3) = e dx
0 3
Calculating the integral:
h i3
P(X < 3) = −e −x/3 = −e −1 − (−1)
0
Thus,
P(X < 3) = 1 − e −1 ≈ 0.6321
(ii). Probability that the call ends between 3 and 5 minutes:
Z 5
1 −x/3
P(3 < X < 5) = e dx
3 3
Calculating the integral:
h i5
P(3 < X < 5) = −e −x/3 = −e −5/3 − −e −1
3
Thus,
P(3 < X < 5) = e −1 − e −5/3 ≈ 0.0996
(iii). Probability that the call ends in more than 4 minutes:
Z ∞
1 −x/3
P(X > 4) = e dx
4 3
Calculating the integral:
h i∞
P(X > 4) = −e −x/3 = 0 − −e −4/3
4
Thus,
P(X > 4) = e −4/3 ≈ 0.2636
Assignment Problems