Probability and Statistics: Random Variables
Probability and Statistics: Random Variables
Random Variables
DBS&H, CEME-NUST
Change in Temperature:
Sample Space y
RR 2
RB 1
BR 1
BB 0
X 6 8 10 12 14
P(X) 0.15 0.3 0.35 0.1 0.1
What is the probability that fewer than 8 or more than 12 use the lab in a
given day?
Random Variable
A random variable is a variable whose values are determined by
chance.
A variable was defined as a characteristic or attribute that can assume
different values. Various letters of the alphabet, such as X, Y, or Z, are
used to represent variables
1 Three coins are tossed and if X is the random variable for the number
of heads, then X assumes the value 0, 1, 2, or 3.
2 Let X denotes the number of games played in a series between two
teams where a team to win four games wins the the Series. Then X
assumes the value 4,5,6 or 7.
3 A shipment of 20 similar laptop computers to a retail outlet contains 3
that are defective. Let X denotes the number of defective laptops
then X assumes the value 0, 1, 2, or 3. If a school makes a random
purchase of 2 of these computers, X denotes the number of defective
laptops for the school then X assumes the value 0, 1 or 2.
4 Let X be a random variable giving the number of heads minus the
number of tails in three tosses of a coin then X assumes the value 3,
1,-1 or -3.
Sample Space m
SJB 3
SBJ 1
BJS 1
JSB 1
BSJ 0
JBS 0
Dr. Zubair Ali Probability and Statistics 13 / 62
Probability Distribution or Distribution
0 ≤ P(X ) ≤ 1
2 The sum of the probabilities of all the events in the sample space must
equal 1; that is, X
P(X ) = 1
Outcomes X 1 2 3 4 5 6
1 1 1 1 1 1
P(X) 6 6 6 6 6 6
X 4 5 6 7
P(X) 0.2 0.175 0.225 0.4
we write f (x) = P(X = x); that is, f (4) = P(X = 4), f (5) = P(X = 5)
and so on. .
Dr. Zubair Ali Probability and Statistics 19 / 62
Discrete Random Variables and Distributions
x1 , x2 , x3 , ··· ,
Sample Space m
SJB 3
SBJ 1
m 0 1 3
BJS 1
p(m) 2/6 3/6 1/6
JSB 1
BSJ 0
JBS 0
3 P(X = x) = f (x)
Rb
3 P(a < X < b) =
a f (x)dx.
is a density function.
Cxn p x q n−x .
Under the assumption that successive births (the “trial”) are independent as
far as the sex of the child is concerned. Thus, with A being the event “a
boy”, n = 3, p = 12 = q, we have
Cxn p x q n−x .
Under the assumption that successive births (the “trial”) are independent as
far as the sex of the child is concerned. Thus, with A being the event “a
boy”, n = 3, p = 12 = q, we have
x 0 1 2 3
f(x) 1/8 3/8 3/8 1/8
Dr. Zubair Ali Probability and Statistics 25 / 62
If a car agency sells 50% of its inventory of a certain foreign car equipped
with side airbags, find a formula for the probability distribution of the
number of cars with side airbags among the next 4 cars sold by the agency.
x 0 1 2 3 4
1 1 3 1 1
f (x) 16 4 8 4 16
The set of ordered pairs (x, f (x)) is called the Probability Mass
Function(PMF) of the discrete random variable X .
X 4 5 6 7
P(X) 0.2 0.175 0.225 0.4
x 0 1 2
68 51 3
f(x) 95 190 190
x 0 1 2 3
f(x) 1/8 3/8 3/8 1/8
dF (x)
We can write P(a < X < b) = F (b) − F (a) and f (x) = dx
0 −∞ ≤ x ≤ x1
f (x ) x1 ≤ x ≤ x2
1
f (x1 ) + f (x2 ) x2 ≤ x ≤ x3
F (x) = f (x1 ) + f (x2 ) + f (x3 ) x3 ≤ x ≤ x4
.
.. ..
.
f (x1 ) + f (x2 ) + · · · + f (xn ) xn ≤ x ≤ ∞
1 1 1 5
F (0) =f (0) = , F (1) = f (0) + f (1) = + = ,
16 16 4 16
1 1 3 11
F (2) =f (0) + f (1) + f (2) = + + = ,
16 4 8 16
1 1 3 1 15
F (3) =f (0) + f (1) + f (2) + f (3) = + + + = ,
16 4 8 4 16
1 1 3 1 1
F (4) =f (0) + f (1) + f (2) + f (3) + f (4) = + + + + = 1.
16 4 8 4 16
0, for x < 0,
1 , for 0 ≤ x < 1,
16
5 , for 1 ≤ x < 2,
F (x) = 16 11
16 , for 2 ≤ x < 3,
15
16 , for 3 ≤ x < 4,
1, for x ≥ 4.
0 m<0
2/6 0 ≤ m < 1
F (m) =
5/6 1 ≤ m < 3
1 m>3
d
f (x) = F (x)
P(a < X < b) = F (b) − F (a) dx
x −1 x x
x2
Z Z Z Z
F (x) = P(X ≤ x) = f (t)dt = f (t)dt + f (t)dt = dt
−∞ −∞ −1 −1 3
0 x < −1
F (x) = x 3 +1
9 −1 ≤ x < 2
1 x ≥2
1 − e −2x x ≥ 0
F (x) =
0 x <0
Find (a) the density function, (b) the probability
that X > 2 and (c) the probability that −3 < X ≤ 4.
Z ∞
d
f (x) = F (x) P(X > 2) = f (x)dx
dx 2
Z 4
P(−3 < X ≤ 4) = f (x)dx
−3
X -3 -1 1 3
P(X) 1/27 2/9 4/9 8/27
Dr. Zubair Ali Probability and Statistics 39 / 62
Formula for the Mean of a Probability Distribution
Outcomes X 1 2 3 4 5 6
1 1 1 1 1 1
P(X) 6 6 6 6 6 6
X 1 1 1 1 1 1
µ= X .P(X ) =1 · +2· +3· +4· +5· +6·
6 6 6 6 P 6 6
1+2+3+4+5+6 X
= = = 3.5
6 N
0, 1, 1, 2, 0, 4, 6, 6, 0, 4, 2, 1, 4, 0, 4, 2, 0, 6, 1, 6
0, 1, 1, 2, 0, 4, 6, 6, 0, 4, 2, 1, 4, 0, 4, 2, 0, 6, 1, 6
50
µ= = 2.5
20
0, 1, 1, 2, 0, 4, 6, 6, 0, 4, 2, 1, 4, 0, 4, 2, 0, 6, 1, 6
50
µ= = 2.5
20
0, 1, 1, 2, 0, 4, 6, 6, 0, 4, 2, 1, 4, 0, 4, 2, 0, 6, 1, 6
50
µ= = 2.5
20
X 5 4 3 4 4
µ= X · P(X ) = 0 ·
+1· +2· +4· +6·
20 20 20 20 20
4 6 16 24 50
= + + + = = 2.5
20 20 20 20 20
Cx4 C3−x
3
f (x) = where x = 0, 1, 2, 3.
C37
C04 C3−0
3
1·1 1 C14 C3−1
3
4·3 12
f (0) = 7
= = , f (1) = 7
= = ,
C3 35 35 C3 35 35
4
C C 3 4
C C 3
6·3 18 4·1 4
f (2) = 2 73−2 = = , f (3) = 3 73−3 = =
C3 35 35 C3 35 35
Cx4 C3−x
3
f (x) = where x = 0, 1, 2, 3.
C37
C04 C3−0
3
1·1 1 C14 C3−1
3
4·3 12
f (0) = 7
= = , f (1) = 7
= = ,
C3 35 35 C3 35 35
4
C C 3 4
C C 3
6·3 18 4·1 4
f (2) = 2 73−2 = = , f (3) = 3 73−3 = =
C3 35 35 C3 35 35
These probabilities match the ones we calculated before.
Cx4 C3−x
3
f (x) = where x = 0, 1, 2, 3.
C37
C04 C3−0
3
1·1 1 C14 C3−1
3
4·3 12
f (0) = 7
= = , f (1) = 7
= = ,
C3 35 35 C3 35 35
4
C C 3 4
C C 3
6·3 18 4·1 4
f (2) = 2 73−2 = = , f (3) = 3 73−3 = =
C3 35 35 C3 35 35
These probabilities match the ones we calculated before.
Now, let’s calculate the expected value using these probabilities:
3
X
E (X ) = x · f (x)
x=0
1 12 18 4
E (X ) = 0 · +1· +2· +3·
35 35 35 35
Cx4 C3−x
3
f (x) = where x = 0, 1, 2, 3.
C37
C04 C3−0
3
1·1 1 C14 C3−1
3
4·3 12
f (0) = 7
= = , f (1) = 7
= = ,
C3 35 35 C3 35 35
4
C C 3 4
C C 3
6·3 18 4·1 4
f (2) = 2 73−2 = = , f (3) = 3 73−3 = =
C3 35 35 C3 35 35
These probabilities match the ones we calculated before.
Now, let’s calculate the expected value using these probabilities:
3
X
E (X ) = x · f (x)
x=0
1 12 18 4 12 36 12 12
E (X ) = 0 · +1· +2· +3· = + + =
35 35 35 35 35 35 35 7
Z ∞
E [X ] = µ = xf (x)dx =⇒
−∞
Z ∞ Z 100 Z ∞
E [X ] = µ = xf (x)dx =⇒ E [X ] = xf (x)dx + xf (x)dx
−∞ −∞ 100
∞
20, 000
Z
E [X ] = x· dx = 200
100 x3
= E [X 2 ] − (E [X ])2
X -1 0 1 2
g(X) 1 0 1 4
f(g(X)) f(-1) f(0) f(1) f(2)
X -1 0 1 2 x2 0 1 4
f(x 2 ) f(-1) f(0) f(1) f(2) f(x 2 ) f(0) f(-1)+f(1) f(2)
Number on balls X 3 4 5
2 1 2
Probabilites f(X) 5 5 5
X
µ = E [X ] = Xf (X ) =
X
σ = E [X 2 ] − µ2 = X 2 f (X ) − µ2
1 999
E (x) = $349. + (−$1) = −$0.65
1000 1000
Z ∞
2 2 2 2
σ = E [(X − µ) ] = E [X ] − µ = x 2 f (x)dx − µ2
−∞
E [aX + b] = aE [X ] + b
Var (aX + b) = a2 Var (X )
X 4 5 6 7 8 9
1 1 1 1 1 1
f(X) 12 12 4 4 6 6
X
µ0r = E [X r ] = x r f (x) (Discrete distribution)
x
Z ∞
µ0r r
= E [X ] = x r f (x)dx (Continuous distribution)
−∞
Note that 2
µ = µ01 , σ 2 = µ02 − µ01
µg (x) = µ
R g∞(x) = E [g (x)] =
7 7
P
E [g (x)] = g (x)f (x) −∞ g (x)f (x)dx
0 r
Px r R∞
8 µr = E [X ] = x x f (x) 8 µ0r = E [X r ] = −∞ x r f (x)dx
Find the mean of X, also Find the expected value of the random
variable g (X ) = X 2 .
2 The density function of the continuous random variable X, the total
number of hours, in units of 100 hours, that a family runs a vacuum
cleaner over a period of one year, is given in
x 0<x <1
f (x) = 2−x 1≤x <2
0 otherwise
Find the average number of hours per year that families run their
vacuum cleaners.