Proof of mean of binomial distribution by differentiation The mean of the binomial distribution, i.e. the expectation for number of events, is $np$. I've seen this proven by rearranging terms so that $np$ comes out. For example here, Relating two proofs of binomial distribution mean
I've also seen the following logic:
$$
 (p+q)^n = \sum_{k=0}^n \binom{n}{k} p^k q^{n-k}\\
p\frac{\partial}{\partial p} (p+q)^n = p\frac{\partial}{\partial p} \sum_{k=0}^n \binom{n}{k} p^k q^{n-k}\\
np (p+q)^{n-1} = \sum_{k=0}^n \binom{n}{k} k p^k q^{n-k}\\
np * 1^{n-1} = \langle k \rangle
$$
in which the fact that $p = 1-q$ is conveniently ignored until the end. Is this a sound proof? If not, could it be improved?

Let $f(x)=(x+q)^n$, where $q=1-p$ is a constant. Then 
$$f(x)=\sum_{k=0}^n \binom{n}{k}x^kq^{n-k}.$$
Differentiate with respect to $x$. We get
$$n(x+q)^{n-1}=\sum_{k=0}^n k\binom{n}{k}x^{k-1}q^{n-k}.$$
Multiply through by $x$, and set $x=p$.
Remark: Here is a nicer proof. Let random variable $X_i$ be equal to $1$ if there is a success on the $i$-th trial, and let $X_i=0$ otherwise. Then our binomial random variable $X$ is equal to $X_1+\cdots+X_n$. By the linearity of expectation we have $E(X)=E(X_1)+\cdots+E(X_n)$. Each $X_i$ has expectation $p$, so $E(X)=np$.
