8 Random Variable
8 Random Variable
Discrete random variable: A random variable that is having only discrete values.
A Continuous random variable is one having a continuous range of values.
Definition of a Random Variable:
We define a real random variable as a real function of elements of a sample space. We shall represent a random
variable by a capital letter (such as W, X, or Y) and any particular value of the random variable by a lower case
letter (such as w, x, or y). Thus, given experimental defined by:
A sample space S with elements s, we assign to every s a real number X(x)
According to some rule and call X(x) a random variable.
Distribution and Expectation of a finite Random Variable:
Let X be a random variable on sample space S with a finite image set; say, 𝑋 𝑆 = 𝑥1 , 𝑥2 , … , 𝑥𝑛 . We make
X(S) into a probability space by defining the probability of 𝑥𝑖 𝑡𝑜 𝑏𝑒 𝑃 𝑋 = 𝑥𝑖 which we write 𝑓 𝑥𝑖 . This
function f on X(S), i.e. defined by 𝑓 𝑥𝑖 = 𝑃 𝑋 = 𝑥𝑖 , is called the distribution or probability function of X
and is usually given in the form of a table
𝐸 𝑋 = 𝑥1 𝑓 𝑥1 + 𝑥2 𝑓 𝑥2 + ⋯ + 𝑥𝑛 𝑓 𝑥𝑛 = 𝑥𝑖 𝑓 𝑥𝑖
𝑖=1
That is, 𝐸 𝑋 is the weighted average of the possible values of X, each value weighted by its probability
Example 1:
A pair of fair dice is tossed. We obtain the finite equiprobable space S consisting of the 36 ordered pairs of
numbers between 1 to 6.
𝑆 = 1,1 , 1,2 , … , 6,6
Let X assign to each point 𝑎, 𝑏 in S the maximum of the numbers, i.e. 𝑋 𝑎, 𝑏 = 𝑚𝑎𝑥 𝑎, 𝑏 . Then X is a
random variable with image set
𝑋 𝑆 = 1,2,3,4,5,6
We compute the distribution f of X:
Similarly,
and
𝒙𝒊 1 2 3 4 5 6
𝑓 𝑥𝑖 1 3 5 7 9 11
36 36 36 36 36 36
𝑛
1 3 5 7 9 11
𝐸𝑋 = 𝑥𝑖 𝑓 𝑥𝑖 = 1 +2 +3 +4 +5 +6 = 4.47
36 36 36 36 36 36
𝑖=1
Now let Y assign to each point 𝑎, 𝑏 in S the sum of the numbers, .i.e. 𝑌 𝑎, 𝑏 = 𝑎 + 𝑏. Then Y is also a
random variable on S with image set:
𝑌 𝑆 = 2,3,4,5,6,7,8,9,10,1,12
The distribution g of Y follows:
𝒚𝒊 2 3 4 5 6 7 8 9 10 11 12
𝑔 𝑦𝑖 1 2 3 4 5 6 5 4 3 2 1
36 36 36 36 36 36 36 36 36 36 36
3
We obtain, for example, 𝑔 4 = 36 from the fact that 1,3 , 2,2 𝑎𝑛𝑑 2,1 are these points of S for which
3
𝑔 4 =𝑃 𝑌=4 = 1,3 , 2,2 , 2,1 =
36
The mean of Y is computed as follows:
𝑛
1 2 1
𝐸𝑌 = 𝑦𝑖 𝑔 𝑦𝑖 = 2 +3 + ⋯ + 12 =7
36 36 36
𝑖=1
the charts which follow graphically describe are above distributions:
6 36
11 36
1 36
1 36
123456 2 3 4 5 6 7 8 9 10 11 12
𝐷𝑖𝑠𝑡𝑟𝑖𝑏𝑢𝑡𝑖𝑜𝑛 𝑜𝑓 𝑋 𝐷𝑖𝑠𝑡𝑟𝑖𝑏𝑢𝑡𝑖𝑜𝑛 𝑜𝑓 𝑌
Example 2:
2 1
A coin weighted so that 𝑃 𝐻 = 𝑎𝑛𝑑 𝑃 𝑇 = is tossed three times. The probabilities of the points in the sample
3 3
space 𝑆 = 𝐻𝐻𝐻, 𝐻𝐻𝑇, 𝐻𝑇𝐻, 𝐻𝑇𝑇, 𝑇𝐻𝐻, 𝑇𝐻𝑇, 𝑇𝑇𝐻, 𝑇𝑇𝑇 are as follows:
2 2 2 8 1 2 2 4
𝑃 𝐻𝐻𝐻 = . . = 𝑃 𝑇𝐻𝐻 = . . =
3 3 3 27 3 3 3 27
2 2 1 4 1 2 1 2
𝑃 𝐻𝐻𝑇 = 3 . 3 . 3 = 27 𝑃 𝑇𝐻𝑇 = 3 . 3 . 3 = 27
2 1 2 4 1 1 2 2
𝑃 𝐻𝑇𝐻 = 3 . 3 . 3 = 27 𝑃 𝑇𝑇𝐻 = 3 . 3 . 3 = 27
2 1 1 2 1 1 1 1
𝑃 𝐻𝑇𝑇 = 3 . 3 . 3 = 27 𝑃 𝑇𝑇𝑇 = 3 . 3 . 3 = 27
Let X be the random variable which assign to each point in S the largest number of successive heads which occurs.
Thus,
𝑋 𝑇𝑇𝑇 = 0
𝑋 𝑇𝑇𝐻 = 𝑋 𝑇𝐻𝑇 = 𝑋 𝐻𝑇𝑇 = 𝑋 𝐻𝑇𝐻 = 1
𝑃 𝐻𝐻𝑇 = 𝑃 𝑇𝐻𝐻 = 2
𝑃 𝐻𝐻𝐻 = 3
The image set of X is 𝑋 𝑆 = 0,1,2,3 . We compute the distribution f of X:
1
𝑓 0 = 𝑃 𝐻𝐻𝐻 =
27
4 2 2 2 10
𝑓 1 = 𝑃 𝐻𝑇𝐻, 𝐻𝑇𝑇, 𝑇𝐻𝑇, 𝑇𝑇𝐻 = + + + =
27 27 27 27 27
4 4 8
𝑓 2 = 𝑃 𝐻𝐻𝑇, 𝑇𝐻𝐻 = + =
27 27 27
8
𝑓 3 = 𝑃 𝐻𝐻𝐻 =
27
This information put in the form of the table as follows:
The mean of X is computed as follows:
𝒙𝒊 0 1 2 3
𝑓 𝑥𝑖 1 10 8 8
27 27 27 27
𝑛
1 10 8 8 50
𝐸𝑋 = 𝑥𝑖 𝑓 𝑥𝑖 = 0 +1 +2 +3 = = 1.85
27 27 27 27 27
𝑖=1
Example 3:
A sample of 3 items is selected at random from a box containing 12 items of which 3 are defective. Find the expected
number E of defective items.
Solution:
12
The sample space S consists of the = 220 distinct equally likely sample of size 3. We note that there are:
3
3 9
= 84 𝑠𝑎𝑚𝑝𝑙𝑒𝑠 𝑤𝑖𝑡ℎ 𝑛𝑜 𝑑𝑒𝑓𝑒𝑐𝑡𝑖𝑣𝑒 𝑖𝑡𝑒𝑚𝑠;
0 3
3 9
= 108 𝑠𝑎𝑚𝑝𝑙𝑒𝑠 𝑤𝑖𝑡ℎ 1 𝑑𝑒𝑓𝑒𝑐𝑡𝑖𝑣𝑒 𝑖𝑡𝑒𝑚;
1 2
3 9
= 27 𝑠𝑎𝑚𝑝𝑙𝑒𝑠 𝑤𝑖𝑡ℎ 2 𝑑𝑒𝑓𝑒𝑐𝑡𝑖𝑣𝑒 𝑖𝑡𝑒𝑚𝑠;
2 1
3 9
= 1 𝑠𝑎𝑚𝑝𝑙𝑒𝑠 𝑤𝑖𝑡ℎ 3 𝑑𝑒𝑓𝑒𝑐𝑡𝑖𝑣𝑒 𝑖𝑡𝑒𝑚𝑠;
3 0
Thus the probability of getting 0,1,2 𝑎𝑛𝑑 3 defective items in respectively 84 220 , 108 220 , 27 220 𝑎𝑛𝑑 1 220 .
Thus the expected number E of defective items is
𝑛 84 108 27 1 165
𝐸𝑋 = 𝑖=1 𝑥𝑖 𝑓 𝑥𝑖 = 0 +1 +2 +3 = = 0.75
220 220 220 220 220
Variance and Standard Deviation
𝑛
𝑉𝑎𝑟 𝑋 = 𝑥𝑖 − 𝜇 2 𝑓 𝑥𝑖 = 𝐸 𝑋 − 𝜇 2 = 𝐸 𝑋 2 − 𝜇𝑥 2
𝑖=1
Where 𝜇 is the mean of X. the standard deviation of X, denoted by 𝜎𝑥 is the (nonnegative) square root of
𝑉𝑎𝑟 𝑋 :
𝜎𝑥 = 𝑉𝑎𝑟 𝑋
Example 4:
Consider the random variable X of example (1) (which assigns the maximum of the numbers showing on a pair
of dice). The distribution of X is
𝒙𝒊 1 2 3 4 5 6
𝑓 𝑥𝑖 1 3 5 7 9 11
36 36 36 36 36 36
, and the mean is 𝜇𝑥 = 4.47. we compute the variance and standard deviation of X.
First we compute 𝐸 𝑋 2 :
𝑛
1 3 5 7 9 11 791
𝐸 𝑋2 = 𝑥𝑖 2 𝑓 𝑥𝑖 = 12 + 22 + 32 + 42 + 52 + 62 = = 21.97
36 36 36 36 36 36 36
𝑖=1
𝑉𝑎𝑟 𝑋 = 𝐸 𝑋 2 − 𝜇𝑥 2 = 21.97 − 19.98 = 1.99
xi -2 1 2 4
1
f(xi) ¼ 1/8 ½ 1/8
0.5
𝑥
−2 − 1 0 1 2 3 4 5
0.4
1.0 (b)
0.8
0.4
0.1 0.2 0.1 0.4 0.2
0.5
x
12
𝑓(𝑥)
1/12 (b)
12 X
𝑎 𝐶𝐷𝐹 𝐹(𝑥)
𝑏 𝑃𝐷𝐹 𝑓(𝑥)
Example 8:
Let X be continuous random variable with the following distribution:
1 𝐺𝑟𝑎𝑝ℎ 𝑜𝑓 𝑓
1
𝑓 𝑥 = 2𝑥 𝑖𝑓 0 ≤ 𝑥 ≤ 2
0 𝑒𝑙𝑠𝑒𝑤ℎ𝑒𝑟𝑒
−1 0 1 2 3
Find cumulative distribution function F and graph it.
Solution:
2 𝐺𝑟𝑎𝑝ℎ 𝑜𝑓 𝐹
1 1 2
𝐹𝑥 = 𝑥 𝑑𝑥 = 𝑥
2 4 1
0
0 𝑖𝑓 𝑥 < 0
1 −1 0 1 2 3
𝐹 𝑥 = 𝑥2 𝑖𝑓 0 ≤ 𝑥 ≤ 2
4
1 𝑖𝑓 𝑥 > 2