A paper I was reading they gave the following result without explanation:
Let $s\in\left\{0,1\right\}^n$ where the probability of 1 occurring is p. Let k be the number of 1s occurring in s. Then $\mathbf{E}[p|k]=\frac{k+1}{n+2}$ .
Intuitively, I would assume $f(p)=p^k*(1-p)^{n-k}$ to be the probability density function. But then I get $\mathbf{E}[p|k]=\int_{0}^{1}x^{k+1}*(1-x)^{n-k}$ which yields a different result.
I'm thankful for any tips! On a side note, I've only done first year probability, hence I'm not very capable.
Your $f(p)$ is not a probability density function but is proportional to the likelihood. So if you have a uniform prior on $[0,1]$ then $f(p)$ is also proportional to the posterior; the scaling factor is essentially a Beta function so the probability density function would be $\dfrac{p^k(1-p)^{n-k}}{B(k+1,n-k+1)}$.
The mean of this posterior distribution would then be $$\dfrac{\int_0^1 p \cdot p^k(1-p)^{n-k} \, dp}{\int_0^1 \quad p^k(1-p)^{n-k} \, dp} = \dfrac{B(k+2,n-k+1)}{B(k+1,n-k+1)}=\dfrac{k+1}{n+2}$$