Module_1__Topic_1
Module_1__Topic_1
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)]