Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Probabilities
Chris Piech
CS109, Stanford University
Frequency Frequency
10 10
20 20
30 30
40 40
50 50
60 60
70 70
80 80
90 90
100 100
Frequency Frequency
10 10
20 20
30 30
40 40
50 50
60 60
Assignment Grades
70 70
80 80
90 90
100 100
We have 2055 assignment distributions from grade scope
Flip a Coin With Unknown Probability
Demo
Four Prototypical Trajectories
Review
Conditional Events
P( EF )
P( E | F ) = where P( F ) > 0
P( F )
F
E
Discrete Conditional Distributions
Continuous Conditional Distributions
• Let X and Y be continuous random variables
§ Conditional PDF of X given Y (where fY(y) > 0):
P (X = x, Y = y)
P (X = x|Y = y) =
P (Y = y)
fX,Y (x, y)@x@y
fX|Y (x, y)@x =
fX|Y (y)@y
fX,Y (x, y)
fX|Y (x, y) =
fX|Y (y)
Conditioning with a
continuous random
variable feels weird at first.
But then it gets good.
P (X = x, E)
P (E|X = x) =
P (X = x)
P (X = x|E)P (E)
=
P (X = x)
fX (x|E)P (E)@x
=
fX (x)@x
fX (x|E)P (E)
=
fX (x)
Anomaly Detection
• Let X be a measure of time to answer a question
• Let E be the event that the user is a human:
P (X = x, E)
P (E|X = x) =
P (X = x)
P (X = x|E)P (E)
=
P (X = x)
fX (x|E)P (E)@x
=
fX (x)@x
fX (x|E)P (E)
=
fX (x)
fX (x|E)P (E)
P (E|X = x) =
fX (x)
fX (x|E)P (E)
P (E|X = x) fX (x)
C
= fX (x|E C )P (E C )
P (E |X = x)
fX (x)
fX (x|E)P (E)
Piech, CS106A, Stanford University
Biometric Keystroke
End Review
We are going to think of
probabilities as random
variables!!!
Frequentist Bayesian
n
X = lim f X|N (x|n) =
n+m!1 n + m
n P (N = n|X = x)fX (x)
⇡ P (N = n)
n+m
§ Symmetric when a = b
a ab
§ E[ X ] = Var ( X ) = 2
a+b ( a + b ) (a + b + 1)
Meta Beta
Used to represent a
distributed belief of a probability
Beta is a distribution for
probabilities
o Beta(1, 1) = Uni(0, 1)
§ So, X ~ Beta(1, 1)
If the Prior was a Beta…
If our belief about X (that random variable for probability) was beta
1
fX (x) = xa 1
(1 x)b 1
B(a, b)
= K2 · xn+a 1
(1 x)m+b 1
X|N ⇠ Beta(n + a, m + b)
Understanding Beta
Damn
Four Prototypical Trajectories
Next level?
Frequency Frequency
10 10
20 20
30 30
40 40
50 50
60 60
70 70
80 80
90 90
100 100
Frequency Frequency
10 10
20 20
30 30
40 40
50 50
60 60
Assignment Grades
70 70
80 80
90 90
100 100
We have 2055 assignment distributions from gradescope
Distributions
Binomial Geometric Exponential
Uniform
Beta Beta
Four Prototypical Trajectories
Normal: No
Four Prototypical Trajectories
Poisson: No
Four Prototypical Trajectories
Exponential: No
Four Prototypical Trajectories
Beta: Yes
Assignment Grades Demo
Assignment id = ‘1613’
Frequency
10 20 30 40 50 60 70 80 90 100
Assignment Grades Demo
Assignment id = ‘1613’
Frequency
10 20 30 40 50 60 70 80 90 100
Frequency
100
100
10
20
30
40
50
60
70
80
90
10
20
30
40
50
60
70
80
90
a = 5.06, b = 3.79
a = 3.46, b = 0.35
Frequency
Frequency
100
100
10
20
30
40
50
60
70
80
90
10
20
30
40
50
60
70
80
90
We have 2055 assignment distributions from grade scope
Beta is a Better Fit
- Binomial
Normal Interpretation
- Normal
Beta Interpretation
Frequency
100
100
10
20
30
40
50
60
70
80
90
10
20
30
40
50
60
70
80
90
a = 5.06, b = 3.79
a = 3.46, b = 0.35
Frequency
Frequency
100
100
10
20
30
40
50
60
70
80
90
10
20
30
40
50
60
70
80
90
These are the distribution of student point probabilitities
Assignment Grades Demo
What is the semantics of E[X]?
Frequency
10 20 30 40 50 60 70 80 90 100
a 8.28
E[X] = = ⇡ 0.7238
a+b 8.28 + 3.16
Not yet J
Four Prototypical Trajectories
Beta:
The probability density
for probabilities
Any parameter for a
“parameterized” random
variable can be thought of
as a random variable.
Ε [CS109]
This is actual midpoint of course
(Just wanted you to know)