I have $X_n$ - number of heads after $n$ coin tosses with $X_n\mid P=p \sim \operatorname{Bin}(n,p) $ and $P \sim \operatorname{U}(0,1)$
I need to find a) $f_{P\mid X_3=2}(p)$, the conditional density function of P given $X_3=2$ and b) determine the maximal likelihood estimator for the probability of getting a head in one coin toss.
I found first the general case of of $f_{P\mid X_n=k}(p)$ via via posterior distribution of $P$ :
$$P(P\le x\mid X_n=k)=\frac{\int_0^xP(X_n=k\mid P=y)\cdot f_P(y)\,dy}{P(X_n=k)}= \frac{\int_0^x{n \choose k}y^k(1-y)^{n-k}\cdot 1 \, dy}{\frac{1}{n+1}}= (n+1)\frac{n!}{k!(n-k)!}\int_0^xy^k(1-y)^{n-k} \, dy.$$ Using Gamma and differentiating, we have:
$$f_{P\mid X_n=k}(p)=\frac{(n+2-1)!}{(k+1-1)!(n+1-k-1)!}\cdot x^k(1-x)^{n-k} \\ = \frac{\Gamma(n+2)}{\Gamma(k+1)\Gamma(n+1-k)} \cdot x^k(1-x)^{n-k},$$ so with $X_3=2$, we have:
$$f_{P\mid X_3=2}(p)=\frac{\Gamma(3+2)}{\Gamma(2+1)\Gamma(3+1-2)} \cdot x^2(1-x)^{3-2} = 12x^2(1-x)$$
a) Did I solve correctly the part a) ?
b) I am not sure how to do part b)?
Thank you very much for any help or feedback!
Part $(a)$ is correctly solved, except that you call the same variable both $x$ and $p.$ You should end up saying $$ f_{P\,\mid\, X_3=2} (p) = 12 p^2(1-p) \quad\text{for } 0\le p\le 1. $$
For part $(b)$ you need to consider $$ L(p) = \Pr(X_3=2) = \text{constant} \times p^2(1-p) $$ and then $$ \ell(p) = \log L(p) = \text{constant} + 2\log p + \log(1-p). $$ Then $$ \ell\,'(p) = \frac 2 p - \frac 1 {1-p}. $$ Set this equal to $0$ and solve for $p.$ That's not enough by itself to prove there's a unique absolute maximum at that point, but you have these additional facts: