What is the probability that the probability of flipping heads is greater than 0.5 if the first four flips are heads? A defective machine produced biased coins whose probability of landing on heads is $p$, where the density function of $p$ is given by
$f(p) = 6(p - p^{2}), 0 < p < 1$
What is the probability that the probability of flipping heads is greater than 0.5 if the first four flips are heads?
What I have so far:
Let X be the random variable for the probability of flipping heads is greater than 0.5 
Let Y be the random variable for flipping the first 4 heads
I want to find 
$P(X|Y) = P(X \cap Y)/P(Y) = [P(Y|X)*P(X)] / P(Y)$
I think that the probability of flipping 4 heads is $p^{4}$ and $P(X) = \int_{0.5}^{1}6(p - p^{2})dp$.
But I'm not sure if $P(Y|X) = \int_{0.5}^{1}p^{4}dp$ and $P(Y) = \int_{0}^{1}p^{4}dp$, or if I should somehow include $f(p)$ into those integrals. 
 A: The basic idea is that you have a prior distribution, which is represented by $f(p)$.  After observing the four heads in four flips, the posterior distribution is different; intuitively, we would expect that it would be weighted more strongly toward a higher value of $p$.  Specifically, Bayes tells us that
$$
f(p \mid \text{four heads})
    = \frac{P(\text{four heads} \mid p) f(p)}
                   {\int_{q=0}^1 P(\text{four heads} \mid q) f(q) \, dq}
$$
where the denominator is a normalizing factor to make sure our distribution sums to $1$.
Certain prior distributions are "convenient" in the sense that the integration works out cleanly, and in these cases, we can often update the posterior distribution by doing simple counting.  In such cases, the prior and posterior distributions are said to be in a conjugate relationship to one another, and the prior distribution family is called a conjugate prior for the likelihood function (the thing that tells you how likely it is to get four heads for a given value of $p$).  It is relevant that $f(p)$ is a Beta distribution, which see.
If this seems confusing, you may not yet be ready to attack this problem.  It seems to assume a certain level of familiarity and comfort with continuous distributions and Bayesian reasoning.
