Professional Documents
Culture Documents
Z Compute
b
f (x|θ)f (θ) dθ
a
http://mathlets.org/mathlets/beta-distribution/
Observation:
The coefficient is a normalizing factor, so if we have a pdf
f (θ) = cθa−1 (1 − θ)b−1
then
θ ∼ beta(a, b)
and
(a + b − 1)!
c=
(a − 1)!(b − 1)!
January 1, 2017 2 /26
Board question preamble: beta priors
Suppose you are testing a new medical treatment with unknown
probability of success θ. You don’t know that θ, but your prior belief
is that it’s probably not too far from 0.5. You capture this intuition
with a beta(5,5) prior on θ.
2.0
1.0
0.0 Beta(5,5) for θ
To sharpen this distribution you take data and update the prior.
Question on next slide.
January 1, 2017 3 /26
Board question: beta priors
(a + b − 1)! a−1
Beta(a, b): f (θ) = θ (1 − θ)b−1
(a − 1)!(b − 1)!
Treatment has prior f (θ) ∼ beta(5, 5)
4. Use what you know about pdf’s to evaluate the integral without
computing it directly
January 1, 2017 4 /26
Solution
9! 4
1. Prior pdf is f (θ) = 4! 4! θ (1 − θ)4 = c1 θ4 (1 − θ)4 .
hypoth. prior C10likelihood
) 6 Bayes numer. posterior
θ c1 θ4 (1 − θ)4 dθ 6 θ (1 − θ)
4 c3 θ10 (1 − θ)8 dθ beta(11, 9)
We know the normalized posterior is a beta distribution because it has the
form of a beta distribution (cθa− (1 − θ)b−1 on [0,1]) so by our earlier
observation it must be a beta distribution.
2. The answer is the same. The only change is that the likelihood has a
coefficient of 1 instead of a binomial coefficent.
3. The posterior on θ is beta(11, 9) which has density
19! 10
f (θ |, data) = θ (1 − θ)8 .
10! 8!
Thus 1 1
19! 11 19! 11! 8! 11
θ (1 − θ)8 dθ = · .= .
0 10! 8! 10! 8! 20! 20
January 1, 2017 6 /26
Conjugate priors
We had
Prior f (θ) dθ: beta distribution
That is, the beta prior becomes a beta posterior and repeated
updating is easy!
Suppose your prior f (θ) in the bent coin example is Beta(6, 8). You
flip the coin 7 times, getting 2 heads and 5 tails. What is the
posterior pdf f (θ|x)?
1. Beta(2,5)
2. Beta(3,6)
3. Beta(6,8)
4. Beta(8,13)
We saw in the previous board question that 2 heads and 5 tails will update
a beta(a, b) prior to a beta(a + 2, b + 5) posterior.
f (x | θ)f (θ) dθ
θ f (θ) dθ f (x | θ) f (x | θ)f (θ) dθ
f (x)
total 1 f (x) 1
1
f (x) = f (x | θ)f (θ) dθ
Observation:
The coefficient is a normalizing factor, so if we have a pdf
2 /2σ 2
f (y ) = ce−(y −µ)
then
y ∼ N(µ, σ 2 )
and
1
c= √
σ 2π
January 1, 2017 11 /26
Board question: normal prior, normal data
1 2 2
N(µ, σ 2 ) has pdf: √ e−(y −µ) /2σ .
f (y ) =
σ 2π
Suppose our data follows a N(θ, 4) distribution with unknown
mean θ and variance 4. That is
f (x | θ) = pdf of N(θ, 4)
C 17 )
The last expression shows the posterior is N 5 , 45 .
January 1, 2017 13 /26
Solution graphs
Data: x1 = 5
Prior is normal: µprior = 3; σprior = 1
Likelihood is normal: µ = θ; σ=2
Posterior is normal µposterior = 3.4; σposterior = 0.894
• Will see simple formulas for doing this update next time.
Juliet knows that θ ≤ 1 hour and she assumes a flat prior for θ on
[0, 1].
On their first date Romeo is 15 minutes late. Use this data to update
the prior distribution for θ.
(a) Find and graph the prior and posterior pdfs for θ.
(b) Find the prior predictive pdf for how late Romeo will be on the
first date and the posterior predictive pdf of how late he’ll be on the
second date (if he gets one!). Graph these pdfs.
See next slides for solution
1.5
1.5
1
1
.5
.5
x
1/8 3/8 5/8 7/8 x
For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms .