Inferring possible future distribution given observed events. I have a process which continues for a possibly infinite amount of time, where some event can either happen or not happen, with equal probability (call it $p$) for each time step. I've observed $n$ time steps so far, and have seen the event happen $k$ times. I would like to figure out the probability of it occurring $K$ times after $N$ time steps.
Clearly you would expect it to occur $k/n*N$ times, but I want to know what the distribution looks like.
I remember bayes theorem from basic maths and so have that P(total value is K | got a value of k) = P(got a value of k | total value is K)*P(total value is K)/P(got a value of k). I know how to evaluate P(got a value of k | total value is K, but I don't know what to do with the terms P(total value is K) or P(got a value of k).
(In reality, the probability isn't exactly independent, and it can only occur a finite number of times, but this is a good enough approximation for my purposes.)
 A: Suppose the actual probability that the event happens is $p$. Then the probability of the observation is ${n \choose k} p^k (1 - p)^{n-k}$. By Bayes' theorem, the posterior density with a uniform prior over the possible values of $p \in [0, 1]$ is 
$$\frac{ {n \choose k} p^k (1 - p)^{n-k} }{\int_0^1 {n \choose k} p^k (1 - p)^{n-k}} = \frac{ p^k (1 - p)^k }{ \int_0^1 p^k (1 - p)^{n-k} \, dp}.$$
In other words,
$$\mathbb{P}(a \le p \le b) = \frac{\int_a^b p^k (1 - p)^{n-k} \, dp }{\int_0^1 p^k (1 - p)^{n-k} \, dp}.$$
This is a beta distribution. The denominator turns out to be $\frac{1}{(n+1) {n \choose k}}$ (beta function).  
This is as far as inferring $p$. From here, the probability that you will subsequently see $K$ events in $N$ steps for a fixed value of $p$ is ${N \choose K} p^K (1 - p)^{N-K}$, hence the probability given the original observation is
$$\int_0^1 {N \choose K} p^K (1 - p)^{N-K} \frac{p^k (1 - p)^{n-k} }{\int_0^1 p^k (1 - p)^{n-k} \, dp} \, dp = {N \choose K} \frac{\int_0^1 p^{k+K} (1 - p)^{(n-k)+(N-K)} \, dp}{\int_0^1 p^k (1 - p)^{n-k} \, dp}$$
which is, if I've juggled all the binomial coefficients correctly,
$$\frac{(n+1){n \choose k} {N \choose K}}{(n+N+1) {n+N \choose k+K}}.$$
