Let's assume i'm given a Probability Distribution as follows:
$$Bin(n; N, p)=\binom{N}{n}p^n(1-p)^{(N-n)}$$
We know that the mean of this distribution is:
$$E[n]=Np$$
However, we want to prove its true using the derivative of the normalized condition of the distribution:
$$\sum_{n=0}^{N}\binom{N}{n}p^n(1-p)^{(N-n)}=1$$
The textbook says that we can derive $E[n]$, the expectation of n, by differentiating both sides of the normalized condition with respect to p, and then rearranging to obtain the expression for the mean of n, aka: $E[n]$.
Ok, So I try to do this by differentiate both sides as follows:
$$\frac{d}{dp}\Bigg( \sum_{n=0}^{N}\binom{N}{n}p^n(1-p)^{(N-n)}\Bigg) = \frac{d}{dp} 1$$
$$\sum_{n=0}^{N}\binom{N}{n} \frac{d}{dp}\Bigg( p^n(1-p)^{(N-n)}\Bigg) = 0$$
Differentiating LHS sub-expression:
$$\frac{d}{dp}\Bigg( p^n(1-p)^{(N-n)}\Bigg)$$
applying product rule of diff:
$$= D\{p^n\}\ (1-p)^{(N-n)} + (p^n)\ D \{(1-p)^{(N-n)}\}$$
$$= n p^{(n-1)} (1-p)^{(N-n)} + (p^n)\ (N-n) (1-p)^{(N-n-1)}(-1)$$
$$= n p^{(n-1)} (1-p)^{(N-n)} - (p^n)\ (N-n) (1-p)^{(N-n-1)}$$
Substituting this result back into Summation:
$$\sum_{n=0}^{N}\binom{N}{n} \frac{d}{dp}\Bigg( n p^{(n-1)} (1-p)^{(N-n)} - (p^n)\ (N-n) (1-p)^{(N-n-1)}\Bigg) = 0$$
Now I'm wondering how do you rearrange this expression to obtain the Expectation of the Binomial Distribution, $E[p]$?
(The Textbook in question is "Pattern Recognition and Machine Learning", 8th printing, 2006, Christoper M. Bishop, page 128, exercise 2.4.)
Differntiation of $$\sum_{n=0}^{N}\binom{N}{n}p^n(1-p)^{(N-n)}=1$$ gives $$\sum_{n=0}^{N}\binom{N}{n} [np^{n-1}(1-p)^{(N-n)}-(N-n)p^{n}(1-p)^{N-n-1}]=0$$ You can write this as
$$\sum_{n=0}^{N}\binom{N}{n} p^n(1-p)^{(N-n)}[\frac n p -\frac {N-n} {1-p}]=0$$
After multiplying by $p(1-p)$ this becomes
$$\sum_{n=0}^{N}\binom{N}{n} p^n(1-p)^{(N-n)}[n -Np]=0$$
Can you finish the proof (by splitting the sum into two parts)?