Professional Documents
Culture Documents
PRP - Unit 2
PRP - Unit 2
PRP - Unit 2
Unit II Probability
Random Variables
1
Random Variable
The outcomes of an experiment may be numeric or non numeric .
Example:
Numeric: Rolling a die, Marks obtained in subject, CGPA
Non Numeric: Tossing a coin, Grade in a subject, Quality
To arrive at logical conclusion, we assign numerical values to non numeric
outcomes .
Definition: Random variable (RV)
A function which associates a unique real number within an interval to
each outcome of sample space of an experiment is known as random
variable.
Symbolically X : S R , where R is a set of real numbers
For every s S there exist a unique real number x R such that X (s) x
Notation: Random variable is denoted by single letter X, and not as
function X(S)
Domain of X = S Range of X = R
2
Examples of Random Variable
Example 1. Toss of a coin
Sample space S = {H, T}
We define random variable as X(H) = 1 , X(T) = 0
Range R = { 0, 1}
Example 2. Three coins are tossed together.
The sample space is
S = {HHH, HHT, HTH, THH, THT, HTT, TTH, TTT }
We define the random variable X = “Number of heads”
X(HHH) = 3, X(HHT ) = 2, X(HTH ) = 2, X(THH ) = 2
X(HTT ) = 1, X(THT ) = 1, X(TTH ) = 1, X(TTT ) = 0
Range
R = { 0, 1, 2, 3}
Example 3. To compute CGPA grades are assigned numerical values.
Example 4. Ages of a group of people
Range = {x | x > 0 }
3
Some useful results
1. If X is a random variable and f(--) is a continuous function and C is a
constant, then 1/X , |X| and CX are also random variables.
3. If X₁, X₂ are two random variables and C₁, C₂ are constants, then
C₁X₁ +C₂ X₂ is also a random variable
4. If X₁, X₂ are two random variables, then max{X₁, X₂} and min{X₁, X₂} are
also random variables.
4
Discrete and Continuous Random Variable
A Random Variable taking only some fixed values is called Discrete Random
Variable.
Example : All the random variables defined in the examples 1,2 and 3.
A Random Variable which can take any value between two extremes is called
Continuous Random Variable.
Basically a continuous random variable can take infinitely many values
between two extremes.
Example: Duration of phone call.
Time of all runners in 100 m race.
Age
5
Events defined by Random Variable
Let X be a random variable and x be a fixed real value.
Let AX be a sub set of S such that all s in AX have the same random variable
value x.
That is AX { s| X (s) x}
Generally used notation for this event is { s | X (s) x} [ X x ]
Since AX [ X isxan
] event of S, it must have a probability.
We write this as
p P[ X x ]
More events can be defined in terms of random variable.
For fixed numbers x, a and b , we define the following events
[ X x ] { s | X (s) x} [ X x ] { s | X (s) x} [a X b] { s |a X (s) b}
These have probabilities denoted by
P[ X x ] Probabilit y that X x
P[ X x ] Probabilit y that X x 1 P[ X x ]
P[a X b] Probabilit y that a X b.
6
Example:
Consider that a fair coin is tossed three times.
Then sample space is
S = {HHH, HHT, HTH, THH, THT, HTT, TTH, TTT }
We define X = Number of heads in each sample point
The range is {0, 1, 2, 3}
Consider the events [X ≤ 1] and [X = 2]
These are given by
[X ≤ 1] ={THT, HTT, TTH, TTT }
[X = 2] = {HHT, HTH, THH}
Therefore P[X ≤ 1] = ½
P [X = 2]= ⅜
7
Distribution Function
Definition : If X is a random variable defined for a sample space S and
[ X x] { s| s S , X (s) x , a x b}
be an event, then the function
FX F (x) P[ X x ]
is called the distribution function of X.
4. F(a) = 0, F(b) = 1
8
Discrete Random Variables Probability Function
Definition : If X is a discrete random variable which can take the values
x₁, x₂, x₃, ..., xn, .... then pi = P[X = xi], where pi satisfies the conditions
(a) pi ≥ 0 for all i, and
(b) i i
p 1
10
Example 1 : If X is a discrete random variable with probability function
X=x -2 -1 0 1
P[X=x] 0.4 k 0.2 0.3
Find k, P[X<0], P[0 X] and distribution function of X.
Answer :
We know that p(x) = 1, therefore
0.4 + k + 0.2 + 0.3 = 1
k = 0.1
P[X<0] = p(-2)+p(-1) = 0.4 + 0.1 = 0.5
P[0 X] = p(0) + p(1) = 0.2 + 0.3 = 0.5
The distribution function of X
F(x) = 0, x < -2
= 0.4 -2 x < -1
= 0.5 -1 x < 0
= 0.7 0x<1
= 1.0 1x
11
Probability Density function &
Cumulative Distribution Function
Definition : Consider a continuous function f(x), f(x) 0 for -∞ < x < ∞, such
that probability of the event [X x], where X is continuous
random variable, is given by
x
P[ X x ] F (x) f (x)dx
The f(x) is known as Probability Density Function (PDF) of
continuous Random variable X.
F(x) is the Cumulative Distribution Function of the random
variable. d
F (x) f (x)
dx
By definition of Probability, we observe that f (x)dx 1
b
Also P[a X b] f (x)dx
a
P[ X x ] 0
Probability of continuous random variable at a point is zero.
12
| x |, 1 x 1
Example 1 : Verify if whether f ( x ) can be a PDF of a continuous random
0, otherwise
variable.
13
Example 2 : Probability density function of a random variable is given by
cxe x , x 0
f ( x)
0, x 0
Find the value of c and Cumulative distribution function (CDF) of x.
Answer: If f(x) is a PDF
x ex ex
f (x)dx 1 cxe dx 1 cx 1 dx 1
0 1 1 0
ex ex c 1
cx 1
1 1 0
x x
The CDF of X = F(x) =P[X x] = f (x)dx xe x dx
0
x
ex ex
x
1 1 0
1 (1 x)e x , x 0
F (x)
0, otherwise
14
Random Variable X may be Discrete or Continuous
Variable Discrete Continuous
Probability P[ X x ] pi 0 P[ X x] 0
Δx Δx
P[x X x ] f (x)Δx
2 2
f (x) 0 for all x
Graphically
15
Discrete Random Variable
Consider that a fair coin is tossed three times.
Then sample space is S = {HHH, HHT, HTH, THH, THT, HTT, TTH, TTT }
We define X = Number of heads in each sample point.
The range is {0, 1, 2, 3} 0.4 0.38 0.38
0.3
The probability distribution is 0.2 p 0.13 0.13
0.1
X 0 1 2 3 0
0 1 2 3
P=P[X=x}] 0.125 0.375 .0375 0.125 RV
xe x , x 0
PDF : f ( x) 0.3
0, x 0
0.2 PDF
f CDF
1 (1 x)e x , x 0 0.1
CDF : F (x) P[ X x ] P[ X 2.25]
0, otherwise 0
0 2 4 6 X 8 10 12 14
16
Graph for PDF and CDF
xe x , x 0 1 (1 x)e x , x 0
PDF : f ( x) CDF : F (x) P[ X x ]
0, x 0 0, otherwise
1.2
0.8
PDF
0.6
f(x)
F(X)
0.4
0.2
0
-2 -1 0 1 2 3 4 5 6
-0.2
17
Characterizing a Population
• Descriptive statistics provides simple summaries about the sample and
about the observations that have been made.
• Such summaries may be either quantitative, i.e. summary statistics, or
visual, i.e. simple-to-understand graphs.
• Examples:
– the shooting percentage in basketball is a descriptive statistic that summarizes the
performance of a player or a team. This number is the number of shots made divided by
the number of shots taken. For example, a player who shoots 33% is making approximately
one shot in every three. The percentage summarizes or describes multiple discrete events.
– Consider GPA the grade point average. This single number describes the general
performance of a student across the range of their course experiences.
• Inferential Statistics is the process of deducing properties of an underlying
distribution by analysis of data. The population is assumed to be larger than
the observed data set; in other words, the observed data is assumed to be
sampled from a larger population.
• Inferential statistical analysis infers properties about a population: this
includes testing hypotheses and deriving estimates.
18
Measures of Characterization
• Measures of central tendency
– Mean
– Median
– Mode
Commonly Used
• Measures of Dispersion
– Range
– Variance
– Standard deviation
19
Expected value of a Random Variable
Let X be a discrete random variable which takes the value xi with probability pi,
i = 1, 2, 3, .........., n.
Then the expectation
n
of this random variable X is defined as
E ( X ) xi pi x1 p1 x2 p2 x3 p3 .............. xn pn
i 1
n
x1 p1 x2 p2 x3 p3 .............. xn pn
Since pi 1, E( X )
i 1 1
x p x p x p .............. xn pn
1 1 2 2 3 3
p1 p2 p3 .............. pn
Thus the expected value can be viewed as the weighted average, with pi’s being
the weights.
If all outcomes xi are equally likely (that is, p1 = p2 = ... = pn), then the weighted
average turns into the simple average.
If the outcomes xi are not equally probable, then the simple average must be
replaced with the weighted average, which takes into account the fact that some
outcomes are more likely than the others.
The intuition is: the expected value of X is what one expects to happen on average.
20
If X is continuous random variable with PDF f(x), then
E( X ) X (s) f ( x)dx
RX
xf ( x)dx
RX
E(X) = Rs. 25
22
kx , x 1,2,3,4,5
Example : If p(x) represents probability, find
0, elsewhere
1.K
2.P(X=x) x being a prime number
3. P[0.5 < X < 2.5 | X >1]
4.The distribution function.
Solution : Given x= 1 2 3 4 5
p(x)= k 2k 3k 4k 5k
5. Since p(x) is probability function, p(x) = 1
1
6. P(X being
k 2k a3k
prime
4k number)
5k 1 15k 1 k
15
P(X 1, 2, 3, 5)
11
7. P(X Bayes’
Using 1) P(X 2) P(X 3) P(X 5) k 2k 3k 5k 11k
theorem
15
1
1
Mass Function
0.8
0.40 0.33
0.27 0.67
0.30 0.20
F(X) 0.6
p 0.20 0.13
0.07
0.10 0.4
0.4
0.00
1 2 3 4 5 0.2
0.2
x 0.07
0
0
<1 <2 <3 <4 <5 >= 5
X
24
Example: Find the expected value of continuous random variable X which has
the PDF
x2
, 1 x 2
f ( x) 3
0,
Solution: else where
2
x2 5
E ( X ) xf ( x)dx x dx
1
3 4
25
Example: Find the expected value of 3X+4 if the continuous random variable
X has the PDF
x2
, 1 x 2
f ( x) 3
0,
else where
Solution :
2 x2
E (3 X 4) (3x 4) f (x)dx (3x 4) dx
1 3
2 2
2 x2 2 x2 x4 x3
E (3 X 4) 3 x dx 4 dx E (3X 4) 3 4
1 3 1 3 12 1 9 1
16 1 8 1
E (3X 4) 3 4
15 31
E (3X 4) 3 4 1
12 12 9 9 12 4
26
Example: A continuous random variable X is distributed over interval (0, 1)
with PDF ax² +bx, where a and b are constants. If the expected value of X is
0.5, find the CDF.
Solution : We know that (PDF)dx 1
1
2
1
2 x3 x2
(ax bx )dx 1 (ax bx )dx 1 a b 1
0 3 2
0
1
x3 x2 a b
a b 1 1 2a 3b 6 (1)
3 2 3 2
0
1 1
x4 x3
Since E ( X ) x(PDF )dx 0.5 x(ax 2 bx )dx 0.5 a b
0 4 3
0
a b
0.5 3a 4b 6 (2)
4 3
Solving equations (1) and (2), we get a 6, b 6
x
F ( X ) P[ X x ] x(PDF )dx
27
Moments of Random Variable
Definition:
The nth moment of a random variable X, for n = 1, 2, 3, ….., is defined as
xin pi , when X is discrete
n n i
E(X ) X
x n f (x)dx , when X is continuous
-
The first moment E(X) is the expected value.
Definition:
Central moment or moment about the mean is the nth moment of
difference of a random variable X from its expected value.
For n = 1, 2, 3, ….., it is given by
(xi X )n pi , when X is discrete
n n i
E[(X X ) ] ( X X )
(x X )n f (x)dx , when X is continuous
-
28
Variance
• The central moment for n =2 is important.
• It is called variance .
• Notation : σ X2 or var( X )
( xi X ) 2 pi , when X is discrete
i
X2 E[( X X ) 2 ] ( X X ) 2
( x X ) 2 f ( x)dx, when X is continuous
-
σ X2 E[( X X )2 ] E[ X 2 2 X X X
2
σ X2 E[ X 2 ] X
2
Show that
var(aX b) a 2 var(X )
29
Importance of Variance
• The square root of variance , σ X is called Standard deviation
• Variance is a measure of spread of PDF (PMF)
• If spread is large variance will be large and if spread is small i.e random
variable has a concentrated PDF or PMF, variance will be small.
• For example consider the following PDF’s for three RV’s X₁, X₂, and X₃
1 , 0 x 4 1 , 0.5 x 3.5 1 ,1 x 3
fX1 (x) 4 fX 2 ( x) 3 fX3 ( x) 2
0, elsewhere 0, elsewhere 0, elsewhere
E ( X1) xfX1 dx var( X1) E ( X12 ) E ( X1) 2
4x 4 x2 64 4
2
dx 2 dx 2 4 1.33333
04 0 4 12 3
E( X 2 ) E( X 2 ) 2 var(X 2 ) 0.75 var( X3 ) 1/ 3 0.33333
• Graphically
30
Probability Density Distribution
0.6
0.5
0.4
f(x) 0.3 f1
f2
0.2 f3
0.1
0
-1 0 1 2 3 4 5
X
E( X1) E( X 2 ) E( X 2 ) 2
31
Example : If the random variable X has the PDF fX (x) ax 3 , 0 x 1
1. What is the value of a ?
2. What is CDF of X ?
3. What is the expected value of X ?
4. What is variance of X ?
5. What is the value of m so that P[X m] = 0.5 ?
Solution : 1
6. Value of faX :(x) is PDF if fX (x)dx 1 ax 3dx 1
0
1
ax 4
1 a4
4 0
7. CDF of X : x
x
FX (x) fX (x)dx 4 x 3dx x 4
0
0, x 0
4
FX (x) x , 0 x 1
1, 1 x
32
3. Expected value of X :
1 4
E (x) xfX (x)dx E (x) 4 x dx 4 E (x)
5
0
4. Variance of X :
16
var( x) E[ X ] E[ X ] x 2 fX (x)dx
2 2
25
1 16 4 16 196
4 x 5dx
0 25 6 25 150
5. value of m so that P[X m] = 0.5 :
m
P[ X m] 0.5 if fX (x)dx 0.5
m4 0.5 m 4 0.5
33
Example : If the random variable X has the CDF
0, x 1
FX (x) 0.5(x 1), 1 x 3
1, x 3
1. What is PDF of X ?
2. What is the expected value of X ?
3. What is the variance of X ?
Solution :
d 0.5, 1 x 3
4. PDF of X : fX (x) FX (x)
dx 0, elsewhere
5. Expected value of X :
3
E ( X ) xfX (x)dx 0.5 x dx
1
6. Variance of X :
3
var( X ) x fX (x)dx E ( X ) 0.5 x 2 dx 0.25
2 2
1
34
Example : Find the expected value and variance of the random variable K
with PMF k
λ λ
pK (k) e k 0,1,2,3.........
k!
Solution : Expected value is given by
λk λ
E (K ) kpK (k) k e
k 0 k 0 k!
λk λk 1 λk
e λ λ
λe λ
λe λ
k 1(k 1)! k 1(k 1)! k 0 k!
λk 1 λk
Now λ λ λe λ
k 1(k 1)! k 0 k!
d λk
d
λe λ
dλ k 1(k 1)! dλ
kλk 1
e λ λe λ E (K 2 ) λe λ e λ λe λ λ λ2
k 1(k 1)!
var( K ) E (K 2 ) E (K ) 2 λ λ2 λ2 λ
var(K ) E (K )
35
Example : A test engineer finds that the CDF of life time, in years, of an
equipment is 0 x0
FX (x) x / 5
1 e 0 x
a. What is the expected life time of equipment ?
b. What is the variance of lifetime of equipment ?
Solution : The PDF is
0 x0
d
fX (x) FX (x) 1 x / 5
dx 5 e 0 x
Expected lifetime
1 x / 5 x / 5 x / 5 x / 5
E ( X ) xf X (x)dx x e dx xe 0 e dx 5e 0 5
0 5 0
Variance of lifetime var( X ) E ( X 2 ) E ( X ) 2
2
0
1
5
E ( X ) x fX (x)dx x 2 e x / 5dx x 2e x / 5 10 xe x / 5 50e x / 5
2
0
50
E (X 2 ) 50 25 25
36
Moment Generating Function
• We know that tx (tx)2 (tx)3 (tx)k
e 1 tx ..........
2! 3! k 0 k!
• For any function g(x) tx
(tx)k
e g(x) g(x)
k 0 k!
(tx )k tk
tx k
tx
e g(x) g(x) e g ( x ) x g ( x )
x x k 0 k! x k 0 k! x
tx
tk k
e g(x)dx x g(x)dx
k 0 k!
Definition:
If etx exists for every value of t in an interval (-h, h), moment generating
function for a random variable X is defined as
tn
e p(x) discrete RV
tx n
E (x ) coefficien t of
n!
M X (t ) E (etx ) tx dn
e f (x)dx continuous RV E ( x ) n M X (t )
n
dt t 0
37
• Although simple to use, it has the disadvantage that it may not exist in
arbitrarily small neighbourhood of zero.
• This can be overcome by using the Characteristic Function
Definition : The characteristic function of random variable is defined as
X (t ) E (e itx )
It exists for all values of t
dn
E ( X ) n X (t ) E (e itx )
n
dt t 0
38
Example : Find nth moment of the random variable whose probability
x
distribution function is f ( x) e , 0 x
Also find out mean and variance.
Solution:
Moment generating function:
M X (t ) E (etx )
M X (t ) e f ( x)dx e tx e x dx
tx
0
e (t 1) x e ( t 1) x 1
M X (t ) M X (t ) M X (t )
t 1 0 t 1 0 t 1
M X (t ) 1 t t 2 t 3 ....... t n .......
tn
E ( X ) coefficien t of
n
E ( X n ) n!
Mean n!
E ( X ) coefficien t of t 1
Variance
var( X ) E ( X 2 ) - E(X) 2 1 1
2
39
Example : Let X = {1, 2, 3, ......., n} and P(X=i) = 1/n for all i. Find the
generating function, mean and variance of random variable.
Solution:
Moment generating function:
M X (t ) E (etx )
n n 1
txi eti
e P( xi )
i 1 i 1 n
1 t
n
e e 2t e3t ............... e nt
Mean
E ( X ) M X (t )
d
dt t 0
1
n
et 2e 2t 3e3t .......... ..... nent
t 0
1 n 1
1 2 3 .......... ..... n
Variance n 2
2 d2 1
E ( X ) 2 M X (t ) 1 4 9 .......... ..... n
2
(n 1)(n 2)
6
dt t 0 n
2
(n 1)(n 2) n 1 n2 1
2
var( X ) E ( X ) [E ( X )] 2
6 2 12
40
i 1
Example: Let X = {1, 2, 3, .......} and P( X i) q pfor all i. Find the generating
function, mean and variance of random variable.
Solution:
Moment generating function:
M X (t ) E (etx ) e P ( xi )
tx
x
e P(i ) e ti q i 1 p
ti
i 1 i 1
p e qe q 2 e 3t ..........
t 2t
pe t 1 qe t q 2 e t 2
..........
1
pe t
1 qe t
Mean 1
p
Variance q
p2
41