Introduction to Random Variables

advertisement
Guess the Bigger Number
Mathematics for Computer Science
MIT 6.042J/18.062J
Team 1:
• Write different integers between 0 and
7 on two pieces of paper
• Show to Team 2 face down
Introduction to
Random Variables
Team 2:
• Expose one paper and look at number
• Either stick or switch to other number
Team 2 wins if gets larger number
Albert R Meyer,
May 3, 2010
lec 13M.1
Strategy for Team 2
switch if threshold Z where
Z is a random integer, 0 Z 6.
May 3, 2010
May 3, 2010
lec 13M.4
Analysis of Team 2 Strategy
Case M: low Z < high
Team 2 wins in this case, so
Pr{Team 2 wins | M} = 1
and Pr{M} =
Albert R Meyer,
May 3, 2010
Case L: Z < low
Team 2 will switch, so wins iff
low card gets exposed
Team 2 will stick, so wins iff
high card gets exposed
Pr{Team 2 wins | H} =
May 3, 2010
lec 13M.5
Analysis of Team 2 Strategy
Case H: high Z
Albert R Meyer,
lec 13M.2
Analysis of Team 2 Strategy
• pick a paper to expose giving each
paper equal probability.
• if exposed number is “small” then
switch, otherwise stick. That is
Albert R Meyer,
Albert R Meyer,
Pr{Team 2 wins | L} =
lec 13M.6
Albert R Meyer,
May 3, 2010
lec 13M.7
1
Analysis of Team 2 Strategy
So 1/7 of time, sure win.
Rest of time, win 1/2, so
Pr{Team 2 wins} =
Albert R Meyer,
May 3, 2010
Does not matter
what Team 1 does!
lec 13M.8
…& Team 1 can play so
Pr{Team 2 wins} whatever Team 2 does
May 3, 2010
lec 13M.10
Random Variables
May 3, 2010
May 3, 2010
lec 13M.9
Informally: an RV is a number
produced by a random process:
•threshold variable Z
•number of larger card
•number of smaller card
•number of exposed card
Albert R Meyer,
May 3, 2010
lec 13M.11
Intro to Random Variables
Informally: an RV is a number
produced by a random process:
•#hours to next system crash
•#faulty chips in production run
•avg # faulty chips in many runs
•#heads in n coin flips
Albert R Meyer,
Albert R Meyer,
Random Variables
Team 1 Strategy
Albert R Meyer,
Analysis of Team 2 Strategy
lec 13M.12
Example: Flip three fair coins
C ::= # heads (Count)
Albert R Meyer,
May 3, 2010
lec 13M.13
2
What is a Random Variable?
Intro to Random Variables
Specify events using values of variables
•[C = 1] is event “exactly 1 head”
Pr{C = 1} = 3/8
•Pr{C 1} = 7/8
•Pr{C·M > 0} = Pr{M>0 and C>0}
= Pr{all heads} = 1/8
Albert R Meyer,
May 3, 2010
Formally,
R:S
Sample space
Albert R Meyer,
lec 13M.14
Independent Variables
lec 13M.15
alternate version:
Pr{R = a AND S = b} =
Pr{R = a} · Pr{S = b}
[R = a], [S = b]
are independent
events for all a, b
May 3, 2010
May 3, 2010
Independent Variables
random variables R,S
are independent iff
Albert R Meyer,
(usually)
Albert R Meyer,
lec 13M.16
May 3, 2010
lec 13M.18
Binomial Random Variable
Binomial Random Variable
Bn,p::= # heads in n independent flips.
Coin may be biased. So 2 parameters
n ::= # flips, p ::= Pr{head}.
C is binomial for 3 flips: C is B3,1/2
Bn,p::= # heads in n independent flips.
Coin may be biased. So 2 parameters
n ::= # flips, p ::= Pr{head}.
C is binomial for 3 flips: C is B3,1/2
for n=5, p=2/3
Pr{HHTTH} =
Pr{H}Pr{H}Pr{T}Pr{T}Pr{H}
(by independence)
for n=5, p=2/3
Pr{HHTTH} =
Albert R Meyer,
May 3, 2010
lec 13M.26
2
3
2
3
3
2 13
Albert R Meyer,
3
2
1 31
3
May 3, 2010
2
3
lec 13M.27
3
Binomial Random Variable
Binomial Random Variable
Bn,p::= # heads in n independent flips.
Coin may be biased. So 2 parameters
n ::= # flips, p ::= Pr{head}.
Bn,p::= # heads in n independent flips.
Coin may be biased. So 2 parameters
n ::= # flips, p ::= Pr{head}.
Pr{each sequence w/i H’s, n-i T’s} =
Pr{get i H’s, n-i T’s} =
(
p 1p
i
Albert R Meyer,
n
pi 1 p
i
)
(
ni
May 3, 2010
Albert R Meyer,
lec 13M.29
Binomial Random Variable
B n,p = i
(
Albert R Meyer,
so
)
ni
May 3, 2010
lec 13M.30
The Probability Density Function
of random variable R,
}=
n
pi 1 p
i
May 3, 2010
Density & Distribution
Bn,p::= # heads in n independent flips.
Coin may be biased. So 2 parameters
n ::= # flips, p ::= Pr{head}.
Pr{
)
ni
lec 13M.31
Uniform Distribution
PDFR(a) ::= Pr{R = a}
n
ni
PDFB i = pi 1 p
n,p
i ()
Albert R Meyer,
(
)
May 3, 2010
lec 13M.32
Team Problems
R is uniform iff PDFR is constant.
R ::= outcome of fair die roll.
Pr{R=1} = Pr{R=2} = ··· = Pr{R=6} = 1/6
S ::= 4-digit lottery number
Pr{S = 0000} = Pr{S = 0001} = ···
= Pr{S = 9999} = 1/10000
Albert R Meyer,
May 3, 2010
lec 13M.34
Problems
24
Albert R Meyer,
May 3, 2010
lec 13M.40
4
MIT OpenCourseWare
http://ocw.mit.edu
6.042J / 18.062J Mathematics for Computer Science
Spring 2010
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
Download