Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Lecture 4
1
Random Variables (Discrete)
Real-valued functions defined on a sample space are random
vars. determined by outcome of experiment, we can
assign probability to possible values of it (them).
Exs: Toss 3 fair coins, let Y be number of H appearing, then
Y is a random var. with possible values (0,1,2,3) with
probability
P{y = 0} = P(T, T, T) = 1/8
P(y = 1) = P(T, T, H), (T, H,T), (H, T, T) = 3/8
P(y = 2) = P(T, H, H), (H, T, H), (H, H, T) = 3/8
P(y = 3) = P(H, H, H) = 1/8
3
3
Since y is between 0 and 3, 1 P ( { y i})
P( y i )
i 0
i 0
2
Distribution functions
The c.d.f. or distribution function F of random variable x is
defined for all real numbers b, b
F(b) = P{x b} denotes prob. that x takes on a value b
Properties
1. F is a non-decreasing function, if a b F(a) < F(b)
F (b) 1
2. blim
3. lim . . .= 0
b
4. F is right continuous. For any b and any decreasing
sequence bn,
n 1 that converges to b,
lim F (bn) F (b)
n
3
Exs: Distribution function of a random variable x is given
0
x 0
x/2
0 x 1
F(x) = 2/3
1 x 2
11/12 2 x 3
1
3 x
Calculate P{x 3}
lim P{x 3 1 } lim F (3 1 ) 11
n
n
12
n
n
4
Calculate P{x = 1}
1 2
P( x 1) P( x 1) F (1) lim F (1 )
1 1
3
2
6
n
Calculate P{x ½}
P{x 1 } 1 P{x 1 } 1 F ( 1 ) 3
2
2
2
4
Calculate P(2 x
4)
P(2 x 4) F (4) F (2) 1
12
(draw graph)
5
Discrete Random Variables
A random variable that can take on at most a countable
number of possible values.
Probability mass function P(a) = P{x = a}
If x can be x1, x2, x3, . . . then
P(xi) 0, i = 1, 2, . . .
P(x) = 0, else
P ( xi) 1
and
i 1
If we have P(0) = ¼ P(1) = ½
P(2) = ¼
(draw graph)
The plot for a random var. of sum of 2 dice are:
(draw graph)
6
Cumulative Distr. Function F can be expressed in terms of
mass function as F(a) = p(x)
all x a
If x is discrete random variable where x1 x2 x3 . . . then
distrib. function F is a step function. The value of F is
constant in intervals [xi-1, xi) and with a step (jump) of
size p(xi) at xi
Exs:
x has probability mass function
P(1) = ¼
p(2) = ½ p(3) = 1/8
P(4) = 1/8
7
Then, the c.d.f is
0
a 1
¼
1 a 2
F(x) = ¾
2 a 3
7/8
3 a 4
1
4a
Step size at any of values 1, 2, 3, 4 is equal to the probability
that x assumes a particular value.
(draw graph)
8
Expected Value: if x is a discrete random variable with probability
mass function p(x) then
expectation or expected value
E[ x] xp( x)
x: p ( x ) 0
This is a weighted average of possible values x can take on each
value, weighted by probability that x assumes it.
If p(0) = ½ = p(1)
E[x] = 0*1/2 + 1 ½ = ½ ordinary avg. of 2 possible values 0 and
1 x can assume
Or if p(0) = ½ p(1) = 2/3 E[x] = 0*(1/2) + 1*(2/3) = 2/3 where
value of 1 is given twice as much weight as value 0 so, p(1) =
2p(0) 2/3 = 2*(1/3)
9
Frequency Interpretation if an infinite sequence of
independent replications of an experiment is done, then for
any event E, the proportion of time that E occurs is p(E).
So, if x can be x1, x2, x3, . . . with p(x1), p(x2), . . . then,
n
average expectation
E[ x] xip ( xi )
i 1
Exs:
Find E[x] where x is outcome of a roll of fair die
Since p(1) = p(2) = . . . p(6) = 1/6
Then, E[x] = 1(1/6) + 2(1/6) + 3(1/6) + . . . 6(1/6) = 7/2
10
Exs
If I is a stock indicator for trading volume V then
I = 1 if V true
Find E[I]
0 if VC true
Since p(1) = p(v), p(0) = 1 – p(A) we haven then E[I] = p(A)
Expected value of indicator is the probability that event
occurs.
11
Expectation of a function of a Random Variable:
Having a discrete random variable and its probability mass
function, we need expected value of some function x, g(x).
One method:
*calculate the prob. mass function of g(x) since it is a discrete
random variable
*calculate E[g(x)] by using expected value definition
Exs X is a random variable with any value in –1, 0, 1 with
x -1
x 0
x 1
P(-1) = .2
P(0) = .5
P(1) = .3
Calculate E[x2] :
12
Let y = x2, it follows that prob. mass function of y is
P(y = 1) = P(x = -1) + P{x = 1} = .5
P{y = 0} = P{x = 0} = .5
hence, E[x2] = E[y] = 1(.5) + 0(.5) = .5
note that .5 = E[x2] (E[x])2 .01
13
Method 2:
if x is discrete random variable that takes on values xi, i ≥ 1
with P(xi) then for any real-valued function g,
E[ g ( x)] g ( xi ) p( xi )
i
Going back to previous example:
E[x2] = (-1)2 (.2) + 02 (.5) + 12 (.3)
= 1(.2 + .3) + 0 (.5)
= .5
14
Corollary
if a and b are constants then E[aX + b] = a E[X] + b
Because E[aX + b] =
(ax b) p( x)
x: p ( x ) 0
=
a
xp( x) b
x: p ( x ) 0
p( x) aE[ x] b
x: p ( x ) 0
The expected value of a random variable x, E[x] is also
referred to as the mean or 1st moment of x. The quantity
E[xn], n 1 is the nth moment of x and, E[xn] =
x
n
p( x)
x: p ( x ) 0
15
Variance
Given x with distribution function F and E[x]. E[x] is
weighted average of all possible values for x. We need the
variation or spread of these values. If x has a mean μ, then
variance of x, Var(x) = E[(x – μ)2]
Or
( x ) 2 p( x)
x
( x 2 2x 2 ) p( x)
x
x 2 p( x) 2 xp( x) 2 p( x)
x
x
x
E[ x 2 ] 2 2 2 E[ x 2 ] 2
That is also Var (x) = E[x2] – (E[x])2
16
Exs
Calculate Var(x) if x is outcome of a fair die rolled
from previous example, E[x] = 7/2 and
E[x2] = 12(1/6) + 22 (1/6) + 32(1/6) + . . . 62 (1/6) = 91/6
Hence, Var(x) = 91/6 – (7/2)2 = 35/12
Identity: for any constants a and b Var(ax + b) = a2 Var(x)
*note that analogous to the mean being center of gravity of a
distrib. of mass, Variance represents moment of inertia
*The SQRT of Var(x) is the STD. deviation of x denoted by SD(x)
=
Var (x)
Discrete random variables are classified according to their prob.
mass function.
17
Exs:
52-card deck is well-shuffled and then cards are turned face
up one by one til Ace appears. Find expect number of
cards that are face up
Let x be number cards face up til ace appears
A = { no ace among first i – 1 cards turned up }
B = { ith card is ace }
(i481 )
4
P(x = i) = P(AB) = P(B/A) P(A) =
.
52 (i 1) (52
i 1 )
P(x) =
49
48
i 1
i ( )4
10.6 11
52
i 1 ( i 1 )(52 i )
18
Exs:
What are Expected number, Var., and S.D. of the number of
spades in a poker hand? (P.H. = set of 5 cards randomly
picked from 52)
A = pick any 12 spades
39
5
(13
)(
i
5 i )
E[ x] i 52
1.25
B = rest of cards
i 0
5
E[ x ] i
2
i 0
(5 )
13
2 i
39
5i
52
5
( )( )
2.430
( )
Thus, Var(x) = 2.43 - (1.25)2 = 0.864 and σx = .864 .93
19
Exs
A professor made 30 exams, 8 tough, 12 medium, 10 easy;
exams are mixed up and 4 are selected at random. How
many will be difficult?
x number of difficult ones
We need E(x), so
x can be 0, 1, 2, 3, 4 and its probability function is
8
i
22
4 i
30
4
( )( )
p(i ) p( x i)
, i 0,1,2,3,4
( )
Values of all p(i.s) i
0
1
2 3
4
p(i)
0.27 .45 .24 .04 .003
E(x) = 0(.27) + 1(.45) + 2(.24) + 3(.04) + 4(.003) = 1.06
20
Continuous Random Variables
Set of possible values is uncountable (lifetime of a transistor,
mars rovers, etc)
X is continuous random variable if there exists a nonnegative
function f, defined for all real x (, ) having the
property that any set B of real numbers:
P{x B} f ( x)dx
B
Probability density function of x
(states that probability that x will be in B may be obtained by
integrating the p.d.f. over set B) it must also satisfy
1 P{x (, )} f ( x)dx
(all probability stmts about x can be answered in terms of f)
21
If B = [a, b] then
b
P{a x b} f ( x)dx
a
if we let a = b then
b
P{x a} f ( x)dx 0
a
(means that probability of a continuous random variable will
assume any fixed value is zero).
a
P{x a} P{x a} F (a) f ( x)dx
22
Exs:
Suppose x is continuous random variable whose p.d.f. is
f ( x)
C ( 4 x 2 x 2 ) 0 x 2
0
else
What is value of C?
Since f is a p.d.f., we have
and thus, C 2 (4 x 2 x 2 )dx 1
f ( x)dx 1
0
3
2
x
C[2 x 2
]
3
x2
x 0
1 C 3
8
Find P(x 1)?
P( x 1) f ( x)dx
1
3
8
2
1
(4 x 2 x 2 )dx 1
2
23
Exs
Lifetime in days of a MEMS wireless transceiver is a random
variable having p.d.f. given by
f(s) 0
100/x2
x 100
x > 100
What’s probability that 2 of 5 such devices needs replacing
within 150 days of continuous operation?
24
Exs
Assume that events Ei, i = 1, 2, 3, 4, 5
ith transceiver will need replacement within the 150 days are
independent
150
P( Ei)
0
150
f ( x)dx 100 x dx 1
100
2
3
thus, from independence of events Ei, the probability is
P(E)
P(EC)
3
1 2 2 3 80
0 ( )( 3 ) ( 3 ) 243
5
2
25
Exs Loss in a stock option, in thousands of dollars, is a
continuous random var. x with density function:
f(x) = k(2x – 3x2) -1 < x < 0
0
else
Calculate k and find prob. the loss is at most $500
Since f is a p.d.f.
,but
f ( x)dx 1
0
0
f ( x)dx (2 x 3 x )dx k (2 x 3 x 2 )dx
k[ x 2 x 3
2
1
0
1
1
2k
26
so,
2k 1 k 1
2
and, loss at most $500 iff x ≥ -1/2, thus
0
1
P( x ) 1 1 (2 x 3x 2 )dx 1 [ x 2 x 3 ]0 1 3
2
2
2
16
2
2
27
Relationship between c.d.f. F and p.d.f. f is
a
F (a) P{x (, a)} f ( x)dx
Differentiating both sides, d F (a) f (a)
da
Density is the derivative of cumulative distr. function. Also, we
can say that, from
b
P{a x b} f ( x)dx
a
P{a
a
x a } 2 f ( x)dx f (a )
a
2
2
2
28
Where is small and when f is continuous at x = a. In other
words, probability that x will be contained in an interval of
length around point a is roughly f(a). f(a) is a measure
of how likely it is the random variable will be near “a”
29