Proof: Mean of distribution using derivative of normalized condition 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.)

Instead say that $$B(k,n,p,q)= {n \choose k} p^k q^{n-k}~~~~~(1)$$ Now write the binomial expansion $$(p+q)^n = \sum_{k=0}^{n} {n \choose k} p^k q ^{n-k}~~~~(2)$$
paretially differentiate both sides $(\frac{\partial}{\partial p}),$ to get
$$\sum_{k=0}^{n} k {n \choose k} p^{k}{q^{n-k}}=np (p+q)^{n-1}~~~~(3)$$
$$<k>=\frac{\sum_{k=0}^{n} k B(k,n,p,q)}{\sum_{k=0}^{n} B(k,n,p,q)}=\frac{np}{p+q}.$$
Finally using $p+q=1$, \you get the required result.
