<s>[INST] Find the sum (Includes binomial coefficients) I came across this question under summation:
Find the sum: $$\sum_{r=0}^n \left[\frac{r}{n} - \alpha \right]^2 {n \choose r}x^r(1-x)^{n-r} $$
To start with this, I wrote it as $\sum_{r=0}^n \left[\frac{r-n\alpha}{n}  \right]^2 {n \choose r}\left(\frac{x}{1-x}\right)^r(1-x)^{n}$
= $(1-x)^{n}\sum_{r=0}^n \left[\frac{r^2+n^2\alpha^2-2n\alpha r}{n^2}  \right] {n \choose r}\left(\frac{x}{1-x}\right)^r$
= $(1-x)^{n}\left[\sum_{r=0}^n \frac{r^2}{n^2} {n \choose r}\left(\frac{x}{1-x}\right)^r + \sum_{r=0}^n \alpha ^2 {n \choose r}\left(\frac{x}{1-x}\right)^r - \sum_{r=0}^n \frac{2\alpha r}{n} {n \choose r}\left(\frac{x}{1-x}\right)^r\right]$
Here, I found the values of individual sums by differentiating the binomial expansion of $\left(1+\frac{x}{1-x}\right)^n$.
I got :
$\sum_{r=0}^n \frac{r^2}{n^2} {n \choose r}\left(\frac{x}{1-x}\right)^r = \frac{nx+n(n-1)x^2}{(1-x)^nn^2}$
$\sum_{r=0}^n \alpha ^2 {n \choose r}\left(\frac{x}{1-x}\right)^r$ = $\alpha^2 \left(\frac{1}{1-x}\right)^n$
$\sum_{r=0}^n \frac{2\alpha r}{n} {n \choose r}\left(\frac{x}{1-x}\right)^r$ = $\frac{2\alpha}{n}\left(\frac{nx}{(1-x)^n}\right)$
Substituting the values, finally I got the sum to be $\frac{x(1-x)}{n}+(x-\alpha)^2$.
Can anyone please verify if the answer is correct?
 [/INST] Correct, and here's an alternative approach that uses the binomial distribution.  Let $X$ be a $\text{Bin}(n,x)$ random variable.  Then $\mathbb{E}[X] = n x$ and $$\mathbb{E}[X^2] = \mathbb{V}[X] + \mathbb{E}[X]^2 = n x(1-x) + (nx)^2.$$
So
\begin{align}
\sum_{r=0}^n \left[\frac{r}{n} - \alpha \right]^2 {n \choose r}x^r(1-x)^{n-r} 
&= \mathbb{E}\left[\frac{X}{n} - \alpha \right]^2 \\
&= \frac{\mathbb{E}[X]^2}{n^2} - \frac{2\mathbb{E}[X]}{n} + \alpha^2 \\
&= \frac{n x(1-x) + (nx)^2}{n^2} - \frac{2nx}{n} + \alpha^2 \\
&= \frac{x(1-x)}{n} + (x-\alpha)^2
\end{align}

As mentioned by @Essaidi, there is an implicit assumption that $x\in[0,1]$ when we use the binomial distribution.  But both sides of the identity are polynomials in $x$ of degree at most $n$, so if it is true for $n+1$ points, it is true for all $x$.  We have shown that it is true for $[0,1]$, so it is true for all $x$.
</s>