Likelihood of next trial given N trials

Forgive me for my notation and lack of formatting prowess, it's been a while since I've done any of this.

We have flipped a biased coin (unknown weight) $n$ times and received $k$ successes (or heads). I am trying to calculate the probability that there be a success on flip $N+1$

If we assume the bias $p$ is sampled uniformly (and is constant throughout the flip), then is the correct way to calculate this:

$\int P(p| X)*p \partial p$ where $X$ is n successes and k failures

thus

$P(p| X) = \frac{P(X|p)*f(p)}{\int_{0}^{1} P(X|p) \partial p}$

Assuming a uniform prior for $p$ and that ${\int_{0}^{1} P(X|p)} = \frac{1}{n+1}$, we get

$\int_{0}^{1} P(X|p)*(n+1)*p \partial p$

where $P(X|p)$ is the binomial probability.

Is this correct?

-
What LaTeX symbol were you trying to produce with \dp? You can see if it has another name (that MathJax can recognize) by using Detexify: detexify.kirelabs.org/classify.html – Arturo Magidin Mar 16 '11 at 19:45
I was trying to do 'integrate with respect to p' – dfb Mar 16 '11 at 19:48
My apologies if I jumped the gun on editing \dp, I didn't know you wanted the partial derivative. – yunone Mar 16 '11 at 19:49
Is not it a martingale? – Viktor Mar 16 '11 at 21:44

You have a problem using $p$ both as a probability or bias and as a density function, so let's use $f(p)$ as the prior density instead. Then $f(p)=1$ since you have assumed it is uniform on $[0,1]$.

It is useful to know that $(n+1) {n \choose k} \int_{x=0}^1 x^k (1-x)^{n-k} \; dx = 1$, related to the Beta distribution

So the posterior density is

$$f(p|k \text{ heads out of } n) = \frac{Pr(k \text{ heads out of } n|p) f(p)}{\int_{q=0}^1 Pr(k \text{ heads out of } n|q) f(q) \, dq}$$ $$= \frac{ {n \choose k} p^k (1-p)^{n-k} 1}{\int_{q=0}^1 {n \choose k} q^k (1-q)^{n-k} 1 \; dq} = (n+1){n \choose k} p^k (1-p)^{n-p}$$

and the answer to the question is

$$Pr({n+1}^\text{th} \text{ trial is heads }| k \text{ heads out of } n) = E[p|k \text{ heads out of } n]$$ $$= \int_{p=0}^1 p \; f(p|k \text{ heads out of } n) \; dp = \int_{p=0}^1 (n+1){n \choose k} p^{k+1} (1-p)^{n-k} \; dp = \frac{k+1}{n+2}$$

-