Came across an interesting question recently and didn't see an answer on here already:
A casino produces coins which, when flipped, will land on heads with probability $p$. The coins are weighted, and for some $x \in [0, 1],$ $P[p \leq x] = x^{3}.$ At a game in the casino, we flip the coin 4 times and see 4 heads. What is the probability that the next flip will be heads?
Here's my thinking: We can get the PDF of $p$ easily from the CDF: $P[p = x] = 3x^{2},$ which implies our expected probability of heads for a coin made in this casino is
$$3\int_{0}^{1}{x^{3}} = \frac{3}{4}.$$
Now, we ask what we expect $p$ to be given that the coin has exhibited a sequence of 4 heads (since, even though the question asks about the next flip, my understanding is that we factor in the information of the 4 heads, rather than invoking Gambler's Fallacy to state the probability would simply be $\frac{3}{4}$ - is my thinking here correct?). My approach to that is as follows:
$$P[p = x | 4H] = P[4H | p = x]\frac{P[p = x]}{P[4H]} = (x^{4})\frac{3x^{2}}{(0.75^{4})} = \frac{3x^{6}}{0.75^{4}}.$$
Integrating this to find an expected value, however, does not yield promising results. Where have I gone wrong?
Let $f_p(x)$ be the pdf of the coin bias, which you evaluated as $f_p(x)= 3 x^2\,\mathbf 1_{x\in[0..1]}$, and that is correct.
Let $H_n$ be the count of heads among $n$ tosses of the coin. $H_n$ is conditionally binomially distributed so $$\begin{align}\mathsf P(H_n=y\mid p=x)~&=~\dbinom ny\, x^y\,(1-x)^{n-y}\,\mathbf 1_{y\in[[0..n]], x\in[0..1]}\\[3ex]\therefore\quad\mathsf P(H_n=n\mid p=x)~&=~ x^n\,\mathbf 1_{x\in[0..1]}\end{align}$$
You seek $\mathsf P(H_5=5\mid H_4=4)$ and this is found by Bayes' Rule and the Law of Total Probability.
$$\begin{align}\mathsf P(H_5=5\mid H_4=4)~&=~\dfrac{\int_{[0..1]}\mathsf P(H_5=5\mid p=x) f_p(x)\,\mathrm d x}{\int_{[0..1]}\mathsf P(H_4=4\mid p=x) f_p(x)\,\mathrm d x}\\[1ex]&~~~\vdots\\[1ex]&= \phantom{\dfrac{7}{8}}\ldots\end{align}$$