I suspect there is a way to do the following sum by hand, but I'm having some trouble: $$\sum_{x=0}^{n} x^{2} {n \choose x} p^{x}(1-p)^{n-x}$$
There are a couple questions like this, but for general $x^{k}$, I wanted to know for k = 2.
I suspect there is a way to do the following sum by hand, but I'm having some trouble: $$\sum_{x=0}^{n} x^{2} {n \choose x} p^{x}(1-p)^{n-x}$$
There are a couple questions like this, but for general $x^{k}$, I wanted to know for k = 2.
On
Take $q$ to be a constant in the following, and use the identity $$ \sum_{x=0}^n \left(n\atop x\right)p^x q ^{n - x} = (p +q )^n.$$ Apply the operator $D = p \,{d\over dp}$ to both sides $k$ times (twice, here), and then set $q = 1-p$, and you'll get the same answer (for $k=2$) as is on this page... i.e., $p^2n (n-1) +pn = (pn)^2 + np(1-p).$
$$\begin{align*} \sum_kk^2\binom{n}kp^k(1-p)^{n-k}&=n\sum_kk\binom{n-1}{k-1}p^k(1-p)^{n-k}\\ &=n\sum_k(k+1)\binom{n-1}kp^{k+1}(1-p)^{n-k-1}\\ &=n\sum_kk\binom{n-1}kp^{k+1}(1-p)^{n-k-1}+n\sum_k\binom{n-1}kp^{k+1}(1-p)^{n-k-1}\\ &=n(n-1)\sum_k\binom{n-2}{k-1}p^{k+1}(1-p)^{n-k-1}+np\sum_k\binom{n-1}kp^k(1-p)^{(n-1)-k}\\ &=n(n-1)\sum_k\binom{n-2}kp^{k+2}(1-p)^{n-2-k}+np\\ &=n(n-1)p^2+np\\ \end{align*}$$