Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
06: Random VariablesLisa Yan
April 17, 2020
1
Random Variables
2
06b_random_variables
Lisa Yan, CS109, 2020
Conditional independence review
3
Next Episode Playing in 5 seconds
Lisa Yan, CS109, 2020
Random variables are like typed
variables (with uncertainty)
int a = 5;
double b = 4.2;
bit c = 1;
š“ is the number of Pokemon we bring to our future battle.
š“ ā 1, 2, ā¦ , 6
šµ is the amount of money we get after we win a battle.
šµ ā ā+
š¶ is 1 if we successfully beat the Elite Four. 0 otherwise.
š¶ ā {0,1}
4
Random variables are like typed variables
name
Random
variablesCS variables
Lisa Yan, CS109, 2020
Random Variable
A random variable is a real-valued function defined on a sample space.
5
Experiment š = š
2. What is the event (set of outcomes) where š = 2?
Outcome
Example:
3 coins are flipped.
Let š = # of heads.
š is a random variable.
1. What is the value of š for the outcomes:
ā¢ (T,T,T)?
ā¢ (H,H,T)?
3. What is š š = 2 ? š¤
Lisa Yan, CS109, 2020
Random Variable
A random variable is a real-valued function defined on a sample space.
6
Experiment š = š
2. What is the event (set of outcomes) where š = 2?
Outcome
1. What is the value of š for the outcomes:
ā¢ (T,T,T)?
ā¢ (H,H,T)?
3. What is š š = 2 ?
Example:
3 coins are flipped.
Let š = # of heads.
š is a random variable.
Lisa Yan, CS109, 2020
Random variables are NOT events!
It is confusing that random variables and events use the same notation.
ā¢ Random variables ā events.
ā¢ We can define an event to be a particular assignmentof a random variable.
7
event
š = 2probability
(number b/t 0 and 1)
š(š = 2)
Example:
3 coins are flipped.
Let š = # of heads.
š is a random variable.
Lisa Yan, CS109, 2020
Random variables are NOT events!
It is confusing that random variables and events use the same notation.
ā¢ Random variables ā events.
ā¢ We can define an event to be a particular assignmentof a random variable.
8
Example:
3 coins are flipped.
Let š = # of heads.
š is a random variable.
š = š {(H, T, T), (T, H, T),
(T, T, H)}
3/8
š = š {(H, H, T), (H, T, H),
(T, H, H)}
3/8
š = š {(H, H, H)} 1/8
š ā„ 4 { } 0
š = š„ Set of outcomes š š = š
š = š {(T, T, T)} 1/8
PMF/CDF
9
06c_pmf_cdf
Lisa Yan, CS109, 2020
So far
3 coins are flipped. Let š = # of heads. š is a random variable.
10
Experiment š = ___Outcome
(flip __ heads)š š = ___
Can we get a āshorthandā for
this last step?
Seems like it might be useful!
Lisa Yan, CS109, 2020
Probability Mass Function
3 coins are flipped. Let š = # of heads. š is a random variable.
11
š(š = š)return value/output
number between
0 and 1
parameter/input š
A function on šwith range [0,1]
What would be a useful function to define?The probability of the event that a random variable š takes on the value š!
For discrete random variables, this is a probability mass function.
Lisa Yan, CS109, 2020
Probability Mass Function
3 coins are flipped. Let š = # of heads. š is a random variable.
12
š(š = š)
2
0.375return value/output:
probability of the event
š = š
parameter/input š:
a value of š
N = 3P = 0.5
def prob_event_y_equals(k):n_ways = scipy.special.binom(N, k)p_way = np.power(P, k) * np.power(1 - P, N-k)return n_ways * p_way
A function on šwith range [0,1]
probability mass function
Lisa Yan, CS109, 2020
A random variable š is discrete if it can take on countably many values.
ā¢ š = š„, where š„ ā š„1, š„2, š„3, ā¦
The probability mass function (PMF) of a discrete random variable is
š š = š„
ā¢ Probabilities must sum to 1:
This last point is a
good way to verify
any PMF you create.
Discrete RVs and Probability Mass Functions
13
š=1
ā
š š„š = 1
shorthand notation
= š š„ = šš(š„)
Lisa Yan, CS109, 2020
PMF for a single 6-sided die
Let š be a random variable that represents the result of a singledice roll.
ā¢ Support of š : 1, 2, 3, 4, 5, 6
ā¢ Therefore š is a discreterandom variable.
ā¢ PMF of X:
š š„ = į1/6 š„ ā {1, ā¦ , 6}0 otherwise
14
1/6
1 2 3 4 5 60
š = š„
šš=š„
Lisa Yan, CS109, 2020
Cumulative Distribution Functions
For a random variable š, the cumulative distribution function (CDF) is defined as
š¹ š = š¹š š = š š ā¤ š ,where āā < š < ā
For a discrete RV š, the CDF is:
š¹ š = š š ā¤ š =
all š„ā¤š
š(š„)
15
Lisa Yan, CS109, 2020
Let š be a random variable that represents the result of a single dice roll.
16
1/6
1 2 3 4 5 60
š = š„
šš=š„
CDFs as graphsCDF (cumulative
distribution function)š¹ š = š š ā¤ š
š¹š
š = š„
5/6
4/6
3/6
2/6
1/6
PMF of š
CDF of š
š š ā¤ 0 = 0
š š ā¤ 6 = 1
Expectation
17
06d_expectation
Lisa Yan, CS109, 2020
Discrete random variables
18
Discrete
Random
Variable, š
Experiment
outcomes
PMF
š š = š„ = š(š„)
Definition
Properties
Support
CDF š¹ š„
Without performing the experiment:
ā¢ The support gives us a ballpark of what values our RV will take on
ā¢ Next up: How do we report the āaverageā value?
Lisa Yan, CS109, 2020
Expectation
The expectation of a discrete random variable š is defined as:
šø š =
š„:š š„ >0
š š„ ā š„
ā¢ Note: sum over all values of š = š„ that have non-zero probability.
ā¢ Other names: mean, expected value, weighted average,center of mass, first moment
19
Lisa Yan, CS109, 2020
Expectation of a die roll
What is the expected value of a 6-sided die roll?
20
Expectation
of ššø š =
š„:š š„ >0
š š„ ā š„
1. Define random variables
2. Solve
š š = š„ = į1/6 š„ ā {1, ā¦ , 6}0 otherwise
š = RV for value of roll
šø š = 11
6+ 2
1
6+ 3
1
6+ 4
1
6+ 5
1
6+ 6
1
6=7
2
Lisa Yan, CS109, 2020
Important properties of expectation
1. Linearity:
šø šš + š = ššø š + š
2. Expectation of a sum = sum of expectation:
šø š + š = šø š + šø š
3. Unconscious statistician:
šø š š =
š„
š š„ š(š„)
21
ā¢ Let š = 6-sided dice roll,
š = 2š ā 1.
ā¢ šø š = 3.5ā¢ šø š = 6
Sum of two dice rolls:
ā¢ Let š = roll of die 1
š = roll of die 2
ā¢ šø š + š = 3.5 + 3.5 = 7
These properties let you avoid
defining difficult PMFs.
Proofs (OK to stop here)
22
Lisa Yan, CS109, 2020
Important properties of expectation
1. Linearity:
šø šš + š = ššø š + š
2. Expectation of a sum = sum of expectation:
šø š + š = šø š + šø š
3. Unconscious statistician:
šø š š =
š„
š š„ š(š„)
23
Review
Lisa Yan, CS109, 2020
Linearity of Expectation proof
šø šš + š = ššø š + š
Proof:
šø šš + š =
š„
šš„ + š š š„ =
š„
šš„š š„ + šš š„
= š
š„
š„š(š„) + š
š„
š š„
= š šø š + š ā 1
24
šø š =
š„:š š„ >0
š š„ ā š„
Lisa Yan, CS109, 2020
Expectation of Sum intuition
šø š + š = šø š + šø š
25
(weāll prove this
in two weeks)
š š š + š
3 6 9
2 4 6
6 12 18
10 20 30
-1 -2 -3
0 0 0
8 16 24
1
7(28)
Average:1
š
š=1
š
š„š1
š
š=1
š
š¦š1
š
š=1
š
š„š + š¦š
Intuition
for now:
+ =
+ =1
7(56)
1
7(84)
šø š =
š„:š š„ >0
š š„ ā š„
Lisa Yan, CS109, 2020
LOTUS proof
26
Let š = š(š), where š is a real-valued function.
šø š š = šø š =
š
š¦šš(š¦š)
=
š
š¦š
š:š š„š = š¦š
š(š„š)
=
š
š:š š„š = š¦š
š¦š š(š„š)
=
š
š:š š„š = š¦š
š(š„š) š(š„š)
=
š
š(š„š) š(š„š)
Expectation
of š ššø š š =
š„
š š„ š(š„)
For you to review
so that you can
sleep at night
Variance
27
07a_variance_i
Lisa Yan, CS109, 2020
Stanford, CA
šø high = 68Ā°F
šø low = 52Ā°F
Washington, DC
šø high = 67Ā°F
šø low = 51Ā°F
28
Average annual weather
Is šø š enough?
Lisa Yan, CS109, 2020
Stanford, CA
šø high = 68Ā°F
šø low = 52Ā°F
Washington, DC
šø high = 67Ā°F
šø low = 51Ā°F
29
Average annual weather
0
0.1
0.2
0.3
0.4
0
0.1
0.2
0.3
0.4
šš=š„
šš=š„
Stanford high temps Washington high temps
35 50 65 80 90 35 50 65 80 90
68Ā°F 67Ā°F
Normalized histograms are approximations of PMFs.
Lisa Yan, CS109, 2020
Variance = āspreadā
Consider the following three distributions (PMFs):
ā¢ Expectation: šø š = 3 for all distributions
ā¢ But the āspreadā in the distributions is different!
ā¢ Variance, Var š : a formal quantification of āspreadā
30
Lisa Yan, CS109, 2020
Variance
The variance of a random variable š with mean šø š = š is
Var š = šø š ā š 2
ā¢ Also written as: šø š ā šø š 2
ā¢ Note: Var(X) ā„ 0
ā¢ Other names: 2nd central moment, or square of the standard deviation
Var š
def standard deviation SD š = Var š
31
Units of š2
Units of š
Lisa Yan, CS109, 2020
Variance of Stanford weather
32
Variance
of šVar š = šø š ā šø š 2
Stanford, CA
šø high = 68Ā°F
šø low = 52Ā°F
0
0.1
0.2
0.3
0.4
šš=š„
Stanford high temps
35 50 65 80 90
š š ā š 2
57Ā°F 124 (Ā°F)2
šø š = š = 68
71Ā°F 9 (Ā°F)2
75Ā°F 49 (Ā°F)2
69Ā°F 1 (Ā°F)2
ā¦ ā¦
Variance šø š ā š 2 = 39 (Ā°F)2
Standard deviation = 6.2Ā°F
Lisa Yan, CS109, 2020
Stanford, CA
šø high = 68Ā°F
Washington, DC
šø high = 67Ā°F
33
Comparing variance
0
0.1
0.2
0.3
0.4
0
0.1
0.2
0.3
0.4
šš=š„
šš=š„
Stanford high temps Washington high temps
35 50 65 80 90 35 50 65 80 90
Var š = 39 Ā°F 2 Var š = 248 Ā°F 2
Variance
of šVar š = šø š ā šø š 2
68Ā°F 67Ā°F
Properties of Variance
34
07b_variance_ii
Lisa Yan, CS109, 2020
Properties of variance
Definition Var š = šø š ā šø š 2
def standard deviation SD š = Var š
Property 1 Var š = šø š2 ā šø š 2
Property 2 Var šš + š = š2Var š
35
Units of š2
Units of š
ā¢ Property 1 is often easier to compute than the definition
ā¢ Unlike expectation, variance is not linear
Lisa Yan, CS109, 2020
Properties of variance
Definition Var š = šø š ā šø š 2
def standard deviation SD š = Var š
Property 1 Var š = šø š2 ā šø š 2
Property 2 Var šš + š = š2Var š
36
Units of š2
Units of š
ā¢ Property 1 is often easier to compute than the definition
ā¢ Unlike expectation, variance is not linear
Lisa Yan, CS109, 2020
Computing variance, a proof
37
Var š = šø š ā šø š 2
= šø š2 ā šø š 2
= šø š2 ā š2= šø š2 ā 2š2 + š2= šø š2 ā 2ššø š + š2
= šø š ā š 2Let šø š = š
Everyone,
please
welcome the
second
moment!
Variance
of šVar š = šø š ā šø š 2
= šø š2 ā šø š 2
=
š„
š„ ā š 2š š„
=
š„
š„2 ā 2šš„ + š2 š š„
=
š„
š„2š š„ ā 2š
š„
š„š š„ + š2
š„
š š„
ā 1
Lisa Yan, CS109, 2020
Let Y = outcome of a single die roll. Recall šø š = 7/2 .
Calculate the variance of Y.
38
Variance of a 6-sided dieVariance
of šVar š = šø š ā šø š 2
= šø š2 ā šø š 2
1. Approach #1: Definition
Var š =1
61 ā
7
2
2
+1
62 ā
7
2
2
+1
63 ā
7
2
2
+1
64 ā
7
2
2
+1
65 ā
7
2
2
+1
66 ā
7
2
2
2. Approach #2: A property
šø š2 =1
612 + 22 + 32 + 42 + 52 + 62
= 91/6
Var š = 91/6 ā 7/2 2
= 35/12 = 35/12
Lisa Yan, CS109, 2020
Properties of variance
Definition Var š = šø š ā šø š 2
def standard deviation SD š = Var š
Property 1 Var š = šø š2 ā šø š 2
Property 2 Var šš + š = š2Var š
39
Units of š2
Units of š
ā¢ Property 1 is often easier to compute than the definition
ā¢ Unlike expectation, variance is not linear
Lisa Yan, CS109, 2020
Property 2: A proof
Property 2 Var šš + š = š2Var š
40
Var šš + š
= šø šš + š 2 ā šø šš + š 2 Property 1
= šø š2š2 + 2ššš + š2 ā ššø š + š 2
= š2šø š2 + 2šššø š + š2 ā š2 šø[š] 2 + 2šššø[š] + š2
= š2šø š2 ā š2 šø[š] 2
= š2 šø š2 ā šø[š] 2
= š2Var š Property 1
Proof:
Factoring/
Linearity of
Expectation
Bernoulli RV
41
07c_bernoulli
Lisa Yan, CS109, 2020
Jacob Bernoulli
42
Jacob Bernoulli (1654-1705), also known as āJamesā, was a Swiss mathematician
One of many mathematicians in Bernoulli family
The Bernoulli Random Variable is named for him
My academic great14 grandfather
Lisa Yan, CS109, 2020
Consider an experiment with two outcomes: āsuccessā and āfailure.ā
def A Bernoulli random variable š maps āsuccessā to 1 and āfailureā to 0.
Other names: indicator random variable, boolean random variable
Examples:ā¢ Coin flip
ā¢ Random binary digit
ā¢ Whether a disk drive crashed
Bernoulli Random Variable
43
š š = 1 = š 1 = šš š = 0 = š 0 = 1 ā šš~Ber(š)
Support: {0,1} Variance
Expectation
PMF
šø š = š
Var š = š(1 ā š)
Remember this nice property of
expectation. It will come back!
Lisa Yan, CS109, 2020
Defining Bernoulli RVs
44
Serve an ad.ā¢ User clicks w.p. 0.2ā¢ Ignores otherwise
Let š: 1 if clicked
š~Ber(___)
š š = 1 = ___
š š = 0 = ___
Roll two dice.ā¢ Success: roll two 6ās
ā¢ Failure: anything else
Let š : 1 if success
š~Ber(___)
šø š = ___
š~Ber(š) šš 1 = ššš 0 = 1 ā ššø š = š
Run a programā¢ Crashes w.p. šā¢ Works w.p. 1 ā š
Let š: 1 if crash
š~Ber(š)
š š = 1 = š
š š = 0 = 1 ā š š¤
Lisa Yan, CS109, 2020
Defining Bernoulli RVs
45
Serve an ad.ā¢ User clicks w.p. 0.2ā¢ Ignores otherwise
Let š: 1 if clicked
š~Ber(___)
š š = 1 = ___
š š = 0 = ___
Roll two dice.ā¢ Success: roll two 6ās
ā¢ Failure: anything else
Let š : 1 if success
š~Ber(___)
šø š = ___
š~Ber(š) šš 1 = ššš 0 = 1 ā ššø š = š
Run a programā¢ Crashes w.p. šā¢ Works w.p. 1 ā š
Let š: 1 if crash
š~Ber(š)
š š = 1 = š
š š = 0 = 1 ā š
(live)06: Random Variables ISlides by Lisa Yan
July 6, 2020
46
Todayās discussion thread: https://us.edstem.org/courses/667/discussion/84211
Lisa Yan, CS109, 2020
Discrete random variables
47
Discrete
Random
Variable, š
Experiment
outcomesš š = š„ = š(š„)
šø š
Definition
Properties
Review
Note: Random Variables
also called distributions
Support
Lisa Yan, CS109, 2020
Event-driven probability
ā¢ Relate only binary eventsā¦ Either happens (šø)
ā¦ or doesnāt happen (šøš¶)
ā¢ Can only report probability
ā¢ Lots of combinatorics
Random Variables
ā¢ Link multiple similar events together (š = 1, š = 2,ā¦ , š = 6)
ā¢ Can compute statistics: report the āaverageā outcome
ā¢ Once we have the PMF (discrete RVs), we can do regular math
48
A Whole New World with Random Variables
Lisa Yan, CS109, 2020
PMF for the sum of two dice
Let š be a random variable that represents the sum oftwo independent dice rolls.
Support of š: 2, 3, ā¦ , 11, 12
š š¦ =
š¦ā1
36š¦ ā ā¤, 2 ā¤ š¦ ā¤ 6
13āš¦
36š¦ ā ā¤, 7 ā¤ š¦ ā¤ 12
0 otherwise
Sanity check:
49
6/36
0
š = š¦
5/36
2 3 4 5 6 7 8 9 10 11 12
4/36
3/36
2/36
1/36
šš=š¦
š¦=2
12
š š¦ = 1
Think, then Breakout Rooms
Then check out the question on the next slide. Post any clarifications here!
https://us.edstem.org/courses/667/discussion/84211
Think by yourself: 1 min
Breakout rooms: 5 min.
50
š¤
Lisa Yan, CS109, 2020
Example random variable
Consider 5 flips of a coin which comes up heads with probability š.Each coin flip is an independent trial. Let š = # of heads on 5 flips.
1. What is the support of š? In other words, what are the values that š can take on with non-zero probability?
2. Define the event š = 2. What is š š = 2 ?
3. What is the PMF of š? In other words, whatis š š = š , for š in the support of š?
51
š¤
Lisa Yan, CS109, 2020
Example random variable
Consider 5 flips of a coin which comes up heads with probability š.Each coin flip is an independent trial. Let š = # of heads on 5 flips.
1. What is the support of š? In other words, what are the values that š can take on with non-zero probability?
2. Define the event š = 2. What is š š = 2 ?
3. What is the PMF of š? In other words, whatis š š = š , for š in the support of š?
52
0, 1, 2, 3, 4, 5
š š = š =52
š2 1 ā š 3
š š = š =5š
šš 1 ā š 5āš
Lisa Yan, CS109, 2020
Expectation
Remember that the expectation of a die roll is 3.5.
53
š = RV for value of roll
šø š = 11
6+ 2
1
6+ 3
1
6+ 4
1
6+ 5
1
6+ 6
1
6=7
2
Review
šø š =
š„:š š„ >0
š š„ ā š„ Expectation: The average value
of a random variable
Lisa Yan, CS109, 2020
Lying with statistics
54
āThere are three kinds of lies:
lies, damned lies, and statisticsā
āpopularized by Mark Twain, 1906
Lisa Yan, CS109, 2020
Lying with statistics
A school has 3 classes with 5, 10, and 150 students.
What is the average class size?
55
1. Interpretation #1
ā¢ Randomly choose a classwith equal probability.
ā¢ š = size of chosen class
šø š = 51
3+ 10
1
3+ 150
1
3
=165
3= 55
2. Interpretation #2
ā¢ Randomly choose a studentwith equal probability.
ā¢ š = size of chosen class
šø š
= 55
165+ 10
10
165+ 150
150
165
=22635
165ā 137
Average student perception of class sizeWhat universities usually report
Interlude for fun/announcements
56
Lisa Yan, CS109, 2020
The pedagogy behind concept checks
ā¢ Spaced practice (vs. āpractice makes perfectā): better memory retention
ā¢ Low-stakes testing: better concept retrieval, actively connect concepts
It is okay if you donāt understand material off-the-bat. In fact,
learning research suggests that you will learn more in the long run.
Announcements
57
Problem Set 2
Out: last Wed.
Due: Friday
Covers: through today(ish)
Problem Set 1
Due: last Wed.
On-time grades: this Wed.
Solutions: next Wed.
https://www.dartmouth.edu/~cogedlab/pubs/Kang(2016,PIBBS).pdf
http://learninglab.psych.purdue.edu/downloads/2006_Roediger_Karpicke_PsychSci.pdfJOKE HERE
Lisa Yan, CS109, 2020
Ethics in Probability: Misleading Averages
āAverages can be misleading when a distribution is heavily skewed at one end, with a small number of unrepresentative outliers pulling the average in their direction. ā
āIn 2011, for example, the average income of the 7,878 households in Steubenville, Ohio, was $46,341. But if just two people, Warren Buffett and Oprah Winfrey, relocated to that city, the average household income in Steubenville would rise 62 percent overnight, to $75,263 per household.ā
58
https://www.nytimes.com/2013/05/26/opinion/sunday/wh
en-numbers-mislead.html
Lisa Yan, CS109, 2020
Important properties of expectation
1. Linearity:
šø šš + š = ššø š + š
2. Expectation of a sum = sum of expectation:
šø š + š = šø š + šø š
3. Unconscious statistician:
šø š š =
š„
š š„ š(š„)59
Roll a die, outcome is š. You win $2š ā 1.
What are your expected winnings?
Review
Let š = 6-sided dice roll.
šø 2š ā 1 = 2 3.5 ā 1 = 6
Lisa Yan, CS109, 2020
Important properties of expectation
1. Linearity:
šø šš + š = ššø š + š
2. Expectation of a sum = sum of expectation:
šø š + š = šø š + šø š
3. Unconscious statistician:
šø š š =
š„
š š„ š(š„)60
Roll a die, outcome is š. You win $2š ā 1.
What are your expected winnings?
Review
What is the expectation of the sum of
two dice rolls?
Let š = 6-sided dice roll.
šø 2š ā 1 = 2 3.5 ā 1 = 6
Let š = roll of die 1, š = roll of die 2.
šø š + š = 3.5 + 3.5 = 7
Lisa Yan, CS109, 2020
Important properties of expectation
1. Linearity:
šø šš + š = ššø š + š
2. Expectation of a sum = sum of expectation:
šø š + š = šø š + šø š
3. Unconscious statistician:
šø š š =
š„
š š„ š(š„)61
Roll a die, outcome is š. You win $2š ā 1.
What are your expected winnings?
Review
What is the expectation of the sum of
two dice rolls?
Let š = 6-sided dice roll.
šø 2š ā 1 = 2 3.5 ā 1 = 6
(next up)
Let š = roll of die 1, š = roll of die 2.
šø š + š = 3.5 + 3.5 = 7
Think, then Breakout Rooms
Then check out the question on the next slide. Post any clarifications here!
https://us.edstem.org/courses/667/discussion/84211
Think by yourself: 1 min
Breakout rooms: 5 min. Introduce yourself!
62
š¤
Lisa Yan, CS109, 2020
Being a statistician unconsciously
Let š be a discrete random variable.
ā¢ š š = š„ =1
3for š„ ā {ā1, 0, 1}
Let š = |š|. What is šø š ?
63
Expectation
of š ššø š š =
š„
š š„ š(š„)
A.1
3ā 1 +
1
3ā 0 +
1
3ā ā1 = 0
B. šø š = šø 0 = 0
C.1
3ā 0 +
2
3ā 1 =
2
3
D.1
3ā ā1 +
1
3ā 0 +
1
31 =
2
3
E. C and D š¤
Lisa Yan, CS109, 2020
A.1
3ā 1 +
1
3ā 0 +
1
3ā ā1 = 0
B. šø š = šø 0 = 0
C.1
3ā 0 +
2
3ā 1 =
2
3
D.1
3ā ā1 +
1
3ā 0 +
1
31 =
2
3
E. C and D
Being a statistician unconsciously
Let š be a discrete random variable.
ā¢ š š = š„ =1
3for š„ ā {ā1, 0, 1}
Let š = |š|. What is šø š ?
64
Expectation
of š ššø š š =
š„
š š„ š(š„)
šø š
1. Find PMF of š: šš 0 =1
3, šš 1 =
2
3
2. Compute šø[š]
Use LOTUS by using PMF of X:
1. š š = š„ ā š„2. Sum up
šø šø š
ā
ā
Think
Then check out the question on the next slide. Post any clarifications here!
https://us.edstem.org/courses/667/discussion/84211
Think by yourself: 2 min
65
š¤(by yourself)
Lisa Yan, CS109, 2020
St. Petersburg Paradox
ā¢ A fair coin (comes up āheadsā with š = 0.5)
ā¢ Define š = number of coin flips (āheadsā) before first ātailsā
ā¢ You win $2š
How much would you pay to play? (How much you expect to win?)
66
Expectation
of š š
A. $10000
B. $āC. $1
D. $0.50
E. $0 but let me play
F. I will not play
šø š š„ =
š„
š š„ š(š„)
š¤(by yourself)
Lisa Yan, CS109, 2020
ā¢ A fair coin (comes up āheadsā with š = 0.5)
ā¢ Define š = number of coin flips (āheadsā) before first ātailsā
ā¢ You win $2š
How much would you pay to play? (How much you expect to win?)
67
St. Petersburg Paradox
1. Define random variables
2. Solve
For š ā„ 0:
Let š = your winnings, 2š.
šø š = šø 2š =1
2
1
20 +1
2
2
21 +1
2
3
22 +āÆ
š š = š =1
2
š+1
=
š=0
ā1
2
š+1
2š =
š=0
ā1
2= ā
Expectation
of š ššø š š„ =
š„
š š„ š(š„)
Lisa Yan, CS109, 2020 68
St. Petersburg + Reality
1. Define random variables
2. Solve šø š =1
2
1
20 +1
2
2
21 +1
2
3
22 +āÆ
=
š=0
š1
2
š+1
2š =
š=0
161
2= 8.5
Expectation
of š ššø š š„ =
š„
š š„ š(š„)
What if dealer has only $65,536?
ā¢ Same game
ā¢ If you win over $65,536, dealer leaves the country
ā¢ Define š = # heads before first tails
ā¢ You win š = $2š
š = log2 65,536
= 16
For š ā„ 0:
Let š = your winnings, 2š.
š š = š =1
2
š+1
Breakout Rooms
Check out the questions on the next slide.Post any clarifications here!
https://us.edstem.org/courses/667/discussion/84211
Breakout rooms: 5 min. Introduce yourself!
69
š¤
Lisa Yan, CS109, 2020
Statistics: Expectation and variance
1. a. Let š = the outcome of a 4-sideddie roll. What is šø š ?
b. Let š = the sum of three rolls of a4-sided die. What is šø š ?
2. Compare the variances ofšµ1~Ber 0.1 and šµ2~Ber(0.5).
3. a. Let š = # of tails on 10 flips of abiased coin (w.p. 0.4 of heads). What is šø š ?
b. What is Var(š)?
70
š¤
Lisa Yan, CS109, 2020
Statistics: Expectation and variance
1. a. Let š = the outcome of a 4-sideddie roll. What is šø š ?
b. Let š = the sum of three rolls of a4-sided die. What is šø š ?
2. Compare the variances ofšµ1~Ber 0.1 and šµ2~Ber(0.5).
3. a. Let š = # of tails on 10 flips of abiased coin (w.p. 0.4 of heads). What is šø š ?
b. What is Var(š)?
71
If you can identify common RVs, just look up statistics instead of re-deriving from definitions.
Lisa Yan, CS109, 2020
Our first common RVs
73
š ~ Ber(š)
š ~ Bin(š, š)
1. The random
variable
2. is distributed
as a3. Bernoulli 4. with parameter
Example: Heads in one coin flip,
P(heads) = 0.8 = p
Example: # heads in 40 coin flips,
P(heads) = 0.8 = p
Review
Next Time: Binomial, Poisson, and more āŗ
74