Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. Heads in Tosses of a Random Coin Let X be a random proportion with a prior distribution that is beta (2, 3). Given
4. Heads in Tosses of a Random Coin Let X be a random proportion with a prior distribution that is beta (2, 3). Given X = p, let I1, 12, 13, ... be i.i.d. Bernoulli (p). a) Plot the prior density of X. In [9] #Answer to a x = np.arange(0, 1.01, 0.01) y stats.beta.pdf(x, a = 2, b = 3) plt.plot(x, y, lw = 2) plt.title('Beta $ (2, 3) $ density'); Beta (2,3) density 1.75 1.50 1.25 1.00 0.75 0.50 0.25 0.00 0.0 0.2 0.4 0.6 0.8 1.0 b) Let H7 == I. For each h = 0, 1, ..., 7, plot the posterior density of X given H7 = h. All 8 plots should be on the same graph. Use as many lines of code as you need. You don't have to include labels and a legend, but the title should say which densities you are plotting. In [16] #Answer to b for i in np.arange(0, 7): x np.arange(0, 1.01, 0.01) y stats.beta.pdf(x, a = 2 + 1, b = 3 + 7 - 1) plt.plot(x, y, lw = 2) plt.title('Beta (r, s) Densities for $0 \leq h \leq 7$'); Beta (r, s) Densities for 0 sh7 4 3 2 1 0 0.0 0.2 0.4 0.6 0.8 1.0 c) What is the MAP estimate of the random probability of heads given H7 = 2? Calculate the estimate using the appropriate formula and confirm that your answer agrees with the estimate visible in the appropriate graph above. d) Find P(I8 = 1 | H = 2). Your answer should be a decimal value. e) Find P(I8 = 1, I9 = 1, I10 = 1 | H7 = 2). Your answer should be a decimal value. Is it equal to the cube of the answer to Part (d)? If not, which is bigger?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started