5.
1 Random Variable
• Definition: Let E be an experiment and S be a sample
space associated with the experiment. A function X that
assigns to every element s ∈ S , a real number, X(s), is
called a random variable.
• The set of all possible values of the random variable X is
called the range space.
• Moreover, the domain of the random variable X is S.
• A random variable, X, is a function that assigns a single,
but variable, value to each element of a sample space.
• A random variable, X, provides a means of assigning
numerical values to experimental outcomes.
• A random variable, X, is a numerical description of the
outcomes of the experiment or a numerical valued function
defined on sample space, usually denoted by capital letters.
Random variable
➢Example: Flip a coin three times, let X be the number of heads in three
tosses.
S Rx
X(S)
HHH 3
HHT 2
HTH 2
HTT 1
THH 2
THT 1
TTH 1
TTT 0
➢X = {0, 1, 2, 3}
2
Random variable
➢Notice that:
➢each possible outcome is assigned a single numeric value,
➢all outcomes are assigned numeric values, and
➢the value assigned varies across the outcomes.
➢The count of the number of heads is a random variable
➢Probability Distribution
➢The probability distribution for a random variable describes how the
probabilities are distributed over the values of the random variable.
3
Types of Random Variables
• Depending upon the numerical values it can assume, a random variable can
be classified into two major divisions.
❖ Discrete Random Variable and
❖ Continuous Random Variable
5.2. Discrete Random Variable
• Definition: Let X be a random variable. If the number of possible values of X
(i.e. Rx) is finite or countably infinite, then we call X as a discrete random
variable. That is, the possible values of X may be listed as x1, x2,…, xn,… In
the finite case, the list terminates and in the countably infinite case the list
continues indefinitely.
Examples:
– Toss a coin n times and count the number of heads.
– Number of children in a family.
– Number of car accidents per week.
– Number of defective items in a given company.
– Number of bacteria per two cubic centimeter of water.
Probability Distribution of Discrete
Random Variable
• Definition: Let X be a discrete random variable. Hence, Rx
consists of at most a countably infinite number of values,
x1, x2,…, with each possible outcome xi we associate a
number P(xi)=P(X= xi) called the probability of xi. The
probabilities P(xi) for i = 1, 2, 3, . . . , n, ... must satisfy the
following two conditions:
I .P ( xi ) 0 foralli
n
II . P ( xi ) = 1
i =1
• The function p defined above is called the probability
function (or point probability function) of the r.v X.
• Furthermore, the tabular arrangement of all possible values
of X with their corresponding probability is called
probability distribution of X.
Probability Distribution of Discrete Random variable
• Example: Roll two six sided dice. Let X be a random variable defined as
sum of the numbers shown up. Construct a probability Distribution of X?
Die 2
1 2 3 4 5 6
1 (1,1) 2 (1,2) 3 (1,3) 4 (1,4) 5 (1,5) 6 (1,6) 7
Die 1 2 (2 ,1) 3 (2,2) 4 (2, 3) 5 (2, 4) 6 (2,5 ) 7 (2, 6) 8
3 (3, 1) 4 (3, 2) 5 (3, 3) 6 (3, 4) 7 (3, 5) 8 (3, 6) 9
4 (4, 1) 5 (4, 2) 6 (4, 3) 7 (4, 4) 8 (4, 5) 9 (4, 6) 10
5 (5, 1) 6 (5, 2) 7 (5, 3) 8 (5, 4) 9 (5, 5) 10 (5, 6) 11
6 (6, 1) 7 (6, 2) 8 (6, 3) 9 (6, 4) 10 (6, 5) 11 (6, 6) 12
X 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 5 4 3 2 1
P(X=x) 36 36 36 36 36 36 36 36 36 36 36
7
5.3. Continuous Random Variable
• Definition: A random variable X is said to be a
continuous random variable if it assumes all
values in some interval (c,d), where c and d are
real numbers.
• Examples:
– Height of students at a certain college .
– Mark of a student.
– Life time of light bulbs.
– Length of time required to complete a given training.
Probability Density Function (pdf) of Continuous Random Variables
➢ A random variable X is said to be a continuous random variable if there
exists a function f, called the probability density function (pdf) of X,
satisfying the following conditions:
a ) f ( x ) 0 for all x
b) f (x )dx = 1
−
c) for any a and b with a b
b
p(a x b ) = f (x )dx
a
9
Probability Density Function (pdf) of Continuous Random Variables
➢Remark
➢Probability at a point is zero
a
p(x = a ) = f (x )dx = 0
a
➢Consider following equality holds for a continuous random variable
b
p(a x b ) = p(a x b ) = p(a x b ) = p(a x b ) = f (x )dx
a
10
Probability Density Function (pdf) of Continuous Random Variables
➢Example 1: Let X be a continuous random variable with probability
density function (pdf):
2 x, if 0 x 1
f (x ) =
0, otherwise
a. verify that f is a pdf
✓ Solution
✓ f is legitimate if it is positive valued and area under curve (green shaded) is one
f (x )dx = 1
RX
1
1
2x
1+1
0 2 xdx = 1 + 1
0
=1 11
Probability Density Function (pdf) of Continuous Random Variables
➢Example 1: Let X be a continuous random variable with probability
density function (pdf):
b. find P(0.5<x<0.75)
2 xdx = (x )
0.75
p(0.5 x 0.75) = 2 0.75
0.5
0.5
= 0.752 − 0.52
= 0.3125
12
Probability Density Function (pdf) of Continuous Random Variables
➢Example 2: For some constant c, the random variable X has probability
density function:
, if 0 x 1
cx 2
f (x ) =
0, otherwise
a. What should be the value of c, so that f is a pdf
f (x )dx = 1
RX
1
cx 2 dx = 1
0
1
cx 2 +1
= 1
2 +1 0
1
c b. Find P(X≥1/2)
x3 = 1
3 0
c=3 13
Conditional Probability in the Case of Continuous Random Variables
➢Recall that for the case of discrete random variables the conditional
probability is given by:
➢The same formulation holds true for the case of continuous random variables
except that A and B take range of values (intervals) rather than discrete values.
14
Conditional Probability in the Case of Continuous Random Variables
➢ Example: The diameter of an electric cable is assumed to be a continuous
random variable, say X, with pdf
6 x(1 − x ), if 0 x 1
f (x ) =
0, otherwise
➢ Compute
1 1 2
P x | x
2 3 3
15
Conditional Probability in the Case of Continuous Random Variables
➢Solution
✓Let A and B 6 x(1 − x ), if 0 x 1
f (x ) =
0, otherwise
✓A∩B:
➢Required: P(A/B)
1
1 1 2
(
p( A B ) = p x = 6 x(1 − x )dx = 3x − 2 x 1 )
1
2 3 2
3 2 1 3
3
1 2 1
3
1
2
1
3
= 3 − 2 − 3 − 2
2 2 3 3
= 0.2407
16
Conditional Probability in the Case of Continuous Random Variables
➢Solution
1
1
p (B ) = p x
2 2
(
= 6 x(1 − x )dx = 3x − 2 x )
2
2 3 3
3 3 1 1
3
3
2 2 2
3
1
2
1
3
= 3 − 2 − 3 − 2
3 3 3 3
= 0.4815
➢Then
p( A B )
p( A / B ) =
p (B )
0.2407
= = 0.4999
0.4815
17
Cumulative distribution function and its properties
➢The cumulative probability function, denoted F(x), shows the probability that X
is less than or equal to x
F (x) = P( X x)
➢Notation: Cumulative distribution function is usually denoted by upper case
alphabets.
➢Theorems
➢If X is a discrete random variable, then
F (x ) = P( X x ) = P(x j ) x j x
j
➢If X is a continuous random variable, then
x
F (x ) = P( X x ) = f (u )du
−
18
Cumulative distribution function and its properties
Example 1: Let S={HH, HT, TH, TT} and X: the number of heads. Clearly, X is a
discrete random variable. Find the CDF of X.
X 0 1 2
P(X=x) 1 2 1
4 4 4
➢Solution
✓The possible values for X are 0, 1, and 2.
0, if x 0
1 / 4, if 0 x 1
F (x ) =
3 / 4, if 1 x 2
1, if x 2
19
Cumulative distribution function and its properties
Example 2: Find the cdf of the random variable X whose pdf is given by
x, if 0 x 1
f (x ) = 2 − x, 1 x 2
0, otherwise
➢Solution
➢By definition CDF, F(X), is P(X≤x)
x
F (x ) = f (t )dt
−
20
Cumulative distribution function and its properties
Example 2: Find the cdf of the random variable X whose pdf is given by
➢Solution
➢For x≤0
x x
F (x ) = f (t )dt = 0dt = 0
− −
➢For 0≤x<1
x
1 2
x x
F (x ) = ( ) 1 2
− f t dt = 0 tdt = t =
2 0 2
x
21
Cumulative distribution function and its properties
Example 2: Find the cdf of the random variable X whose pdf is given by
➢Solution
➢For 1≤x<2
x 0 1 x
F (x ) = f (t )dt = 0dt + (t )dt + (2 − t )dt
− − 0 1
1 x
1 1
= 0 − + t 2 + 2t − t 2
0
2 0 2 1
1 1 1
= 0+ + 2 x − x 2 − 2 −
2 2 2
1 2
= 2x − x −1
2
22
Cumulative distribution function and its properties
Example 2: Find the CDF of the random variable X whose pdf is given by
➢Solution x 0 1 2 x
➢For x≥2 F (x ) = f (t )dt = 0dt + (t )dt + (2 − t )dt + 0dt +
− − 0 1 2
1 2
1 1
= 0 − + t 2 + 2t − t 2 + 0
0
2 0 2 1
➢Hence the CDF of X is
0, if x0
1 x2 , if 0 x 1
2
F (x ) =
2 x − 1 x 2 − 1, if 1 x 2
2
1, if 2
23
Cumulative distribution function and its properties
➢Theorem:
➢If X is a continuous random variable, then we have
f (x ) = F (x )
d
dx
➢If X is a discrete random variable, then we have
p (x j ) = F (x j ) − F (x j −1 )
➢Remark: P(a ≤ X ≤ b)=F(b)-F(a)
24
Cumulative distribution function and its properties
➢Example: Suppose X is a continuous random variable with cdf
0, if x 0
F (x ) =
1 − e −x
, if x 0
➢Find the pdf of X
➢Solution
f (x ) = F (x )
d
dx
f (x ) =
d
dx
(
1 − e−x )
e − x , if x 0
f (x ) =
0, otherwise
25
Cont.
• Example: If the probability density function of the random variable X is
given by
f (x ) =
1
( 2 x − 1)
144
for x = 1, 2, 3, ..., 12 then find the cumulative distribution function of X.
Cont.
• The space of the random variable X is given by
RX = {1, 2, 3, ..., 12}
• F(1) = 1/144
• F(2) =4/144
………………
………………
• F(12)=1
Cont.
• If the space𝑅𝑋 of the random variable X is given by RX = {x1 < x2 < x3 < ·
· · < xn}, then
f(x1) = F(x1)
f(x2) = F(x2) - F(x1)
f(x3) = F(x3) - F(x2)
.. ........
.. ........
f(xn) = F(xn) - F(xn-1).
Cont.
• Example: Find the probability density function of the random variable X
whose cumulative distribution function is
0.00, if x −1
0.25, if − 1 x 1
F ( x ) = 0.5, if 1 x 3
0.75, if 3 x 5
1 if 5
Cont.
• f(-1) = 0.25
f(1) = 0.50 - 0.25 = 0.25
f(3) = 0.75 - 0.50 = 0.25
f(5) = 1.00 - 0.75 = 0.25.
Cont.
• Example: What is the probability density function of the random variable whose cdf is
1
F(x) =
(1 +𝑒 −𝑥 ) -∞< x < ∞
𝑑
• f(x) = F(x)
𝑑𝑥
𝑒 −𝑥
= (1 +𝑒 −𝑥 )2
EXPECTATION
➢ Most probability distributions are characterized by their mean and variance.
➢ The mean of a random variable is referred to as expectation, provided the
expected value converges to a constant.
➢ If we want to summarize a random variable by a single number, then this
number should undoubtedly be its expected value.
➢ The expected value, also called the expectation or mean, gives the center in
the sense of average value of the distribution of the random variable.
➢ If we allow a second number to describe the random variable, then we look
at its variance, which is a measure of spread of the distribution of the
random variable.
Expectation of a random variable
➢ Definition (Expectation of a discrete random Variable)
➢ Let X be a discrete random variable with possible values x1, x2,
…, xn.
➢ Let p(xi) i=1, 2, 3…n.
➢ Then the expected value of X, denoted by E(X), is defined as:
E( X ) = xi p(xi )
➢ Note: If the series converges absolutely, this number is also called
the mean of X.
• Example 1: A manufacturer produces items such that 10% are
defective and 90% are non-defective. If a defective item is
produced the manufacturer loses $1 and if a non-defective
item is produced the manufacturer gets $5 profit. Find the
expected net profit of the manufacturer per item.
➢ Solution : Expected value of a random variable is
E ( X ) = xi p ( xi )
= (loss ) p(deffetive) + ( profit ) p(nondeffetive)
= (− 1 0.10 ) + (5 0.90 )
= 4.4
➢ On average a manufacturer will get a profit of $4.4
• Definition (Expectation of a continuous random Variable)
➢ Let X be a continuous random variable with possible values x1,
x2, …, xn.
➢ Let f(xi) i=1, 2, 3…n.
➢ Then the expected value of X, denoted by E(X), is defined as:
E ( X ) = xf ( x )dx
Rx
➢ Note: If the series converges absolutely, this number is also called
the mean of X.
Example:
➢ Let X has a pdf
2(1 − x ), 0 x 1
f (x ) =
0, Otherwise
➢ Find the expected value of X.
Solution: E ( X ) = xf ( x )dx
Rx
1
= 2 x(1 − x )dx
0
1
2
= x 1 − x
2
3 0
=1
3
Properties of Expectation
1. If C is any constant value, then E(C) = C
2. E(CX) = C ∗ E(X)
3. If X and Y are any two random variables, then
E(X + Y) = E(X) + E(Y)
4. If X and Y be two independent random variables, then
E(XY) = E(X) ∗ E(Y)
5. If a and b are any constant numbers, then E(a + bX)= a + bE(X)
6. E(X) > 0 if X > 0
7. |E(X)| ≤ E(|X|)
8. E(g1(x)) ≤ E(g2(x)) if g1(X) ≤ g2(X) for all x
Variance of a random variable and its properties
➢ Definition: Let X be a random variable. The variance of
X, denoted by V(X) is defined as:
➢ That is, the mean value of the square of the deviations of
X from its mean is called the variance of X or the
variance of the distribution.
➢ The positive square root of V(X) is called the standard
deviation of X and it is denoted by s.d(X).
➢ It is worthwhile to observe that
➢ The standard deviation of X may be interpreted as a
measure of the dispersion of the points of the space
relative to the mean value E(X).
➢ Example 1: Let X is a discrete random variable with probability distribution
• What is the V(X)?
• Solution :
( )( )( )( )
E ( X ) = xp(x ) = 0 1 + 1 3 + 2 3 + 3 1 = 1.5
8 8 8 8
E (X ) = x p(x ) = (0 1 )+ (1 3 )+ (2 3 )+ (3 1 ) = 3
2 2 2 2 2 2
8 8 8 8
V (X ) = E X ( ) − E ( X )
2 2
= 0.75
➢ Example 2: Let x has a pdf
• What is the V(X)?
➢ Solution
x +1
1
E ( X ) = x dx
−1
2
1
1x x 3 2
= +
2 3 2 −1
1 13 12 1 − 13 − 12
= + − +
2 3 2 2 3 2
1
=
3
x +1
E (X 2 ) = x 2
1
dx
−1 2
1
1x 4
x
3
= +
2 4 3 −1
1 14 13 1 − 14 − 13
= + − +
2 4 3 2 4 3
1
=
3
( )
V ( X ) = E X 2 − E ( X )
2
2
1 1 2
= − =
3 3 9
Properties of Variance
➢ Let X be a random variable
➢ For any real number k, Var(kX ) = k 2Var(X )
➢ The expression E[(X −k) 2] assumes its minimum value when k=E(X)
➢ If Y is another variable that is independent from X, then
Var (X + Y) = Var (X − Y) = Var(X) + Var(Y)
➢ If X and Y are not independent, i.e., if they are dependent then
Var (X + Y) = Var(X) + Var(Y) + 2(E(XY) – E(X)E(Y))
➢ The expression E(XY) – E(X)E(Y) is called the Covariance of X and
Y.
Cov(X, Y) = E(XY) – E(X)E(Y)
➢ Note that: If X and Y are independent then Cov(X, Y) = 0
• Let X be a continuous random variable with probability
density function (pdf):
f(x)= 2x if 0<x<1
0, otherwise
Find E(X)
• Let S={HH, HT, TH, TT} and X: the number of heads.
Clearly, X is a discrete random variable. Find E(X).
x 0 1 2
P(x) 1/4 2/4 1/4