02 Random Variables
02 Random Variables
January 2025
Plan
Introduction
Discrete random variables
Continuous random variables
Expectation of a random variable
Variance of a random variable
Jointly distributed random variables
2
Random variables
3
A random variable is obtained by assigning a numerical value to each
outcome of a particular experiment.
4
Example 1 (Machine breakdowns)
repair cost
outcome probability (in USD)
electrical 0.2 200
mechanical 0.5 350
misuse 0.3 50
5
Example 4 (power plant operation)
X = no. of power plants working and its possible values are 0, 1, 2, and 3
6
7
Types of random variables
8
Types of random variables
Lowercase letters (e.g. x, y, etc.) are used to denote values taken by the
random variable
E.g. X denote the number of power plants generating electricity and its
values are denoted by lowercase letters x = 0, x = 1, etc.
9
Homework 2B
10
Discrete random variables
11
Probability mass function
Probability mass function (pmf) is defined for a discrete random variable and
it assigns probability values to all possible values of the random variable
The probability mass function of a discrete random variable X is a set of
probability values p assigned to values of random variable x
i
P (X = x) = px
12
Probability distribution of repair costs of machine breakdown
13
Probability distribution of the number of plants generating electricity
xi 0 1 2 3
pi 0.07 0.23 0.57 0.13
14
Cumulative distribution function
= ∑ P (X = y)
y: y≤a
15
Probability distribution of repair costs of machine breakdown
16
Cumulative distribution function
17
Cumulative distribution function
function
If there is no step in the cumulative distribution function at a point x
−
F (x) = F (x ) and P (X = x) = 0
18
−
P (X = 40) = F (40) − F (40 ) = 0
−
P (X = 50) = F (50) − F (50 ) = .30 − 0 = .30
−
P (X = 65) = F (65) − F (65 ) = .30 − .30 = 0
19
Homework 2A
2.1.1 An office has four copying machines, and the random variable X
measures how many of them are in use at a particular moment in time.
Find P (X = 4) for the given probabilities
P (X = 0) = 0.08, P (X = 1) = 0.11,
P (X = 2) = 0.27, P (X = 3) = 0.33
20
Homework 2A
2.1.3 Suppose that two fair dice are rolled and that the two numbers recorded
are multiplied to obtain a final score.
Construct and plot the probability mass function and the cumulative
distribution function of the final score
21
Continuous Random Variables
22
Example 14 (Metal Cylinder Production)
23
Example 15 (Battery failure times)
24
Example 17 (Milk contents)
25
Probability density function
The main distinction between discrete and continuous random variables lies
in how their probabilistic properties are defined.
The probabilistic properties of discrete random variables are defined
through a probability mass function
The probabilistic properties of a continuous random variable are defined
through a probability density function
26
Probability density function
27
Probability density function
The probability that a continuous random variable lies between two values a
and b is obtained by integrating the probability density function between
these two values
P (a ≤ X ≤ b) = P (a < X < b)
= ∫ f (x) dx
a
28
Probability density function
P (X = a) = ∫ f (x) dx = 0
a
29
Example 15 (Battery failure times)
30
Example 15 (Battery failure times)
What is the probability that the battery fails within first five hours?
31
Example 15 (Battery failure times)
What is the probability that the battery fails within first five hours?
5 5
2 −1 ∣ −1 35
P (X ≤ 5) = ∫ dx = ∣ = + 1 =
3 2 2
0
(1 + x) (1 + x) ∣ 6 36
0
What is the probability that a battery lasts longer than five hours?
32
Example 17 (Milk container contents)
33
Example 17 (Milk container contents)
34
The probability that the actual amount of milk is less than 2.0 liter
2.0 2.0
−x
∫ f (x) dx = ∫ (40.976 − 16x − 30e ) dx
1.95 1.95
2.0
∣
2 −x
= (40.976x − 16(x /2) + 30e )∣
∣
1.95
2 −2.0
= [(40.976)(2.0) − 16(2.0 /2) + 30e ]
2 −1.95
− [(40.976)(1.95) − 16(1.95 /2) + 30e ]
F (a) = P (X ≤ a) = ∫ f (x) dx
−∞
36
Cumulative Distribution Function
For a continuous random variable, the probability density function can also
be obtained from cumulative distribution function
dF (x)
f (x) =
dx
37
Example 15 (Battery failure times)
38
Cumulative distribution function
x
F (x) = ∫ f (y) dy
0
x
2
= ∫ dy
3
0
(1 + y)
1
= 1 −
2
(1 + x)
39
Example 15 (Battery failure timesY)
40
Example 15 (Battery failure timesY)
Find the probability that a battery lasts between one and two hours
2
P (1 ≤ X ≤ 2) = ∫ f (x) dx
1
2 2
2 −1 ∣ 1 1
= ∫ dx = ∣ = − = 0.21
(1 + x)
3
(1 + x)
2 ∣ 4 25
1 1
P (1 ≤ X ≤ 2) = F (2) − F (1)
1 1 1 1
= [1 − ] − [1 − ] = − = 0.21
2 2
(1 + 2) (1 + 1) 4 25
41
Homework 2B
Check that the total area under the probability density function is equal to 1.
What is P (4.5 ≤ X ≤ 5.5) ?
42
Homework 2B
What is P (X ≤ 2) ?
What is P (1 ≤ X ≤ 3) ?
43
Homework 2B
45
The Expectation of a Random Variable
46
Expectation of a discrete random variable
μ = E(X) = ∑ P (X = xi ) xi = ∑ pi xi
i i
47
Example 1 (Machine breakdowns)
repair cost
outcome probability (in USD)
electrical 0.2 200
mechanical 0.5 350
misuse 0.3 50
48
Example 4 (power plant operation)
xi 0 1 2 3
pi 0.07 0.23 0.57 0.13
49
Expectation of Continuous Random Variables
E(X) = ∫ xf (x) dx
x
50
Example 15 (Battery Failure Times)
∞ ∞
2 2
E(X) = ∫ x dx E(X) = ∫ x dx
3 3
0
(1 + x) 0
(1 + x)
∞ ∞
2 2 2(y − 1)
= ∫ [ − ]dx = ∫ [ ]dy
2 3 3
0
(1 + x) (1 + x) 1
y
∞ ∞
−2 1 2 2
= [ + ] = [ − ]
2 2 3
(1 + x) (1 + x) y y
0 1
= 1 = 1
51
Properties of expectation
E(aX) = aE(X)
52
Homework 2C
2.3.1 An office has four copying machines, and the random variable X
measures how many of them are in use at a particular moment in time.
Suppose that
P (X = 0) = 0.08
P (X = 1) = 0.11
P (X = 2) = 0.27
P (X = 3) = 0.33.
53
Homework 2C
54
Homework 2C
2.3.12 Consider again the car panel painting machine discussed in Problem
2.2.6, where
2
f (x) = A[0.5 − (x − 0.5) ], 0.125 ≤ x ≤ 0.5
55
The Variance of a Random Variable
56
The Variance of a Random Variable
2
2
σ = V ar(X) = E[X − E(X)]
2 2
= E[X − 2XE(X) + E(X) ]
2 2 2
= E(X ) − 2E(X) + E(X )
2 2
= E(X ) − E(X)
2 2
= E(X ) − μ
57
Standard deviation
The positive square root of the variance is known as the standard deviation,
which is denoted by σ
2
σ = +√ σ = +√V ar(X)
58
Example 1 (Machine breakdowns)
59
Expected value
E(X) = ∑ xi pi = 230
Variance
2 2
V ar(X) = E(X ) − E(X)
2 2
= ∑ x pi − E(X)
i
2
= 70, 000 − 230 = 17, 100
Standard deviation
60
Example 14 (Metal cylinder diameter)
Expected value
50.5 .5
2 2
E(X) = ∫ x[1.5 − 6(x − 50.0) ]dx = ∫ (y + 50)(1.5 − 6y )dy
49.5 −.5
.5
3 2
= ∫ (1.5y − 6y + 75 − 300y )dy
−.5
.5
2 4 3
= [(1.5y /2) − (6y /4) + 75y − (300y /3)] = 50
−.5
61
Example 14 (Metal cylinder diameter)
Variance
2 2 2
V ar(X) = E(X ) − E(X) ] = 2500.05 − 50 = 0.05
62
.5
2 2 2
E(X ) = ∫ (y + 100y + 2500)(1.5 − 6y )dy
−.5
.5
2 4 3 2
= ∫ [1.5y + 150y + 3750 − 6y − 600y − 15000y ]dy
−.5
0.5
3 2 5 4 3
= [.5y + 75y + 3750y − (6y /5) − (600y /4) − 5000y ]
−.05
63
Properties of variance
2
V (aX) = a V (X)
2
V (a + bX) = b V (X)
64
Quantiles
65
Medians of Random Variables
F (xm ) = 0.5
66
Medians of Random Variables
2
⇒ (1 + x) = 2
⇒ x = √2 − 1 = 0.41
67
Symmetric distribution
68
Quantiles
F (xp ) = P (X ≤ xp ) = p
69
Quartiles
70
Inter-quartile range
71
Quartiles
72
Example 15 (Battery Failure Times)
73
Example 15 (Battery Failure Times)
1
⇒ = 0.25 ⇒ x.75 = 1 hr
2
(1 + x.75 )
1
F (x.25 ) = .25 ⇒ 1 − = .25
2
(1 + x.25 )
1
⇒ = 0.75 ⇒ x.25 = .154 hr
2
(1 + x.25 )
74
Example 15 (Battery Failure Times)
Half of the batteries will fail between 0.154 hour and 1 hour (i.e. between
about 9 minutes to 60 minutes)
75
Homework 2D
2.4.1 Suppose that the random variable X takes the values −2, 1, 4, and 6 with
probability values 1/3, 1/6, 1/3, and 1/6, respectively.
Find the expectation and variance of X.
76
Homework 2D
2.4.5 Consider again the random variable described in Problems 2.2.2 and
2.3.10 with a probability density function of
1
f (x) = , 4 ≤ x ≤ 6.
x ln(1.5)
2.4.6 Find variance, standard deviation, and interquartile range of the variable
X , where
2
x
F (x) = f or 0 ≤ x ≤ 4
6
78
Jointly Distributed Random Variables
79
Jointly Distributed Random Variables
For two discrete random variables X and Y , the joint probability mass
function is defined by
P (X = xi , Y = yj ) = pij
∑ ∑ pij = 1
i j
80
Jointly Distributed Random Variables
For two continuous random variables X and Y , the joint probability density
function is defined by f (x, y) that satisfies
∫ ∫ f (x, y) dy dx = 1
x y
81
Jointly Distributed Random Variables
The probability that X lies between a and b, and Y lies between c and d is
defined as
b d
P (a ≤ X ≤ b, c ≤ Y ≤ d) = ∫ ∫ f (x, y) dy dx
a c
F (x, y) = P (X ≤ x, Y ≤ y) = ∫ ∫ f (u, v) dx dy
−∞ −∞
82
Example 19 (Air Conditioner Maintenance)
83
Example 19 (Air Conditioner Maintenance)
P (X = 1, Y = 1) = p11 = 0.12
P (X ≤ 1, Y ≤ 2) = p11 + p12
85
Marginal probability distributions
P (X = xi ) = ∑ P (X = xi , Y = yj )
E.g. P (X = 1) = ∑ P (X = 1, Y = yj )
j=1
86
87
Marginal probability distributions
f1 (x) = ∫ f (x, y) dy
−∞
f2 (y) = ∫ f (x, y) dx
−∞
88
Marginal probability distributions
P (X = x) = ∑ P (X = x, Y = y)
y
P (Y = y) = ∑ P (X = x, Y = y)
x
89
Conditional probability distribution
f (x, y)
f2 | 2
(x|y) = (continuous)
f (y)
90
Conditional probability distribution
For example
P (X = 2, Y = 1) .08
P (Y = 1 | X = 2) = = = .33
P (X = 2) .24
91
Independent random variables
92
Independent random variables
1 1
1
2 3
f (x) = ∫ f (x, y)dy = ∫ 6xy dy = [6xy /3] = 2x
0
0 0
1 1
1
2 2 2 2
f (y) = ∫ f (x, y)dx = ∫ 6xy dx = [6x y /2] = 3y
0
0 0
93
Homework 2E
2.5.3 Suppose that two continuous random variables X and Y have a joint
probability density function
f (x, y) = A(x − 3)y, −2 ≤ x ≤ 3, 4 ≤ y ≤ 6
94
3 6
∫ ∫ A(x − 3)y dy dx = 1
−2 4
3 6
2 ∣
A∫ (x − 3)[(y /2)∣ ]dx = 1
∣
−2 4
10A ∫ (x − 3) dx = 1
−2
3
2∣
10A(x /2 − 3x) = 1
∣
−2
10A[(9/2) − 9 − 2 − 6] = 1
10A(−25/2) = 1
A = −(1/125)
95