# The probability of heads of a random coin is uniform r.v. P. Find the probability that heads will show?

The question states:

The probability of heads of a random coin is a random variable P, uniform in the interval $[0.4,0.6]$. Find the probability that at the next tossing of the coin that heads will show. Suppose the coin is tossed $50$ times resulting in $21$ tails and $29$ heads. What is $P(p|Observed Data)$?

My first question is what is the probability of P. It seems like there are two different ways to look at it. Is the probability such that $f(p)=5$ for $0.4 \le p \le 0.6$ and zero otherwise, thus $$P(H) = \int_{0.4}^{0.6}pdp = 0.5$$ or on the other hand does it follow the standard simple uniform distribution. That is $$P[0.4 \le P \le 0.6] = \int_{0.4}^{0.6} dp = 0.2$$

Then, to answer the second part, is it correctly broken down by $$\frac{p^{29}(1-p)^{21}}{\int_{0.4}^{0.6}p^{29}(1-p)^{21}dp}$$ for $0.4 \le p \le 0.6$ and $0$ otherwise. Thus, we obtain $$P(H|A) = \int_{0.4}^{0.6} pf(p|A)dp$$

Thank you so much for your help in advance, I really appreciate it!

• Your random variable $P$ has a uniform distribution over $[.4, .6]$, and so $P[.4 \leq P\leq .6]=1$. The PDF of $P$ is $f_P(p) = \frac{1}{.2}$ for $p \in [.4, .6]$ (and 0 else). Note that phrases "probability of $p$" and "probability of $P$" do not make sense, since probabilities are defined on events ("Probability that $P > .5$" is something that makes sense). You likely are supposed to compute the conditional PDF of $P$: $$f_{P|Data}(p|Data=(21,29))=\frac{P[Data=(21,29)|P=p]f_P(p)}{P[Data=(21,29)]}$$ and compute $P[Data=(21,29)]$ by conditioning on $P=p$ via the law of total probability. – Michael Oct 17 '16 at 3:02
• PS: I do not know what "H" or "A" mean in your question. – Michael Oct 17 '16 at 3:07

Although the result you arrive to regarding the question of what is the probability we should assign to heads before seeing the coin tosses is correct, your reasoning is not. To simplify notation I will use $\theta$ instead of $P$ to denote the random variable which represents the coin bias.
First we want to find $P(H|\theta\ is \ uniform\ in\ [0.4,0.6])$. But this is the same as $\int_{0.4}^{0.6} P(H|\theta = x) \pi_{\theta}(x) dx$, where $\pi$ is the prior density of $\theta$ and it is $\pi_\theta(x) = \frac{I_{[0.4,0.6]}(x)}{0.6-0.4}$.
Substituting, we have that $P(H) = \int_{0.4}^{0.6} x \frac{1}{0.6-0.4}(x) dx=\frac{1}{2}$.
Now we want to do a Bayes update given the data on the coin tosses. If we denote by $B(n, h, p)$ the mass distribution of a binomial, where $n$ is the number of coin tosses, $h$ the number of heads and $p$ the coin bias, then: $$f(\theta = x|Data) = \pi_{\theta}(x)\frac{P(Data|\theta = x)}{P(Data)}= \pi_{\theta}(x)\frac{B(50,29, x)}{\int_{0.4}^{0.6}B(50,29, y)\pi_\theta(y)dy}= \frac{1}{0.6-0.4}\frac{{50 \choose 29} x^{29} (1-x)^{21}}{\int_{0.4}^{0.6}{50 \choose 29} y^{29} (1-y)^{21} \frac{1}{0.6-0.4}dy}= \frac{ x^{29} (1-x)^{21}}{\int_{0.4}^{0.6} y^{29} (1-y)^{21}dy}$$ Thus the result is a beta distribution with a rather hideous denominator.