Please use D2L to turn in both the HTML output and your R Markdown file in.

### Q1. (10 pts)

Assume you are trying to model a binomial probability, \(\theta\). Given a prior distribution on \(\theta\), \(p(\theta) \sim Beta(a,b)\) and where \(\mathcal{D}\) represents the observed data with \(N\) Bernoulli trials with \(z\) successes, show that the posterior \(p(\theta|\mathcal{D}) \sim Beta(a+z,b+N-z)\).

The equation is started below for you in LaTex. I’d recommend giving it a try with LaTex and I’ll give you an extra credit point for using Latex, but if you need to you can turn in a PDF of a hand written equation.

\[\begin{eqnarray}
p(\theta|\mathcal{D}) &=& \frac{p(\mathcal{D})|\theta)p(\theta)}{p(\mathcal{D})|\theta)p(\theta)}\\
&=& \frac{\Gamma(a)\Gamma(b)/\Gamma(a+b) \theta^{a-1} (1-\theta)^{b-1} \times \theta^z (1-\theta)^{N-z}} {\int (\Gamma(a)\Gamma(b)/\Gamma(a+b)) \theta^{a-1} (1-\theta)^{b-1} \times \theta^z (1-\theta)^{N-z} d\theta}\\
&=& \\
&=& \\
&=& \\
&=& \frac{\Gamma(a+z)\Gamma(b+N-z)}{\Gamma(a+b+N)} \theta^{a+z-1} (1-\theta)^{b+N-z-1}\\
&\sim & Beta(a+z, b+N-z) \\
\end{eqnarray}\]
### Q2. (9 pts)

#### a. (3 pts)

Discuss the \(a\) parameter in the Beta distribution. How does this relate to \(z\), the number of successes from the \(N\) Bernoulli trials?

#### b. (3 pts)

Discuss the \(b\) parameter in the Beta distribution. How does this relate to \(N-z\), the number of failures from the \(N\) Bernoulli trials?

#### c. (3 pts)

Discuss the \(a+b\) in the Beta distribution. How does this relate to the \(N\) Bernoulli trials?

### Q3. (12 pts) (DBDA, question 6.5)

#### a. (4 pts)

Suppose you have a coin that you know is minted by the government and has not been tampered with. Therefore you have a strong belief that the coin is fair. You flip the coin 10 times and get 9 heads. What is your predicted probability of heads for the 11th flip? Explain your answer carefully; justify the choice of prior.

#### b. (4 pts)

Now you have a different coin, this one made of some strange material and marked (in fine print) “Patent Pending, International Magic, Inc.” You flip the coin 10 times and get 9 heads. What is your predicted probability of heads on the 11th flip? Explain your answer carefully; justify your choice of prior.

#### c. (4 pts)

Finally, assume you have not been trained in Bayesian statistics, what is your predicted probability of the 11th coin flip for the previous two scenarios? Explain your answer carefully and discuss the implications of Bayesian analysis in these settings.