# Why are these two summations in the calculation of the variance equal?

Background: The screenshot below is the book solution to a 1st year probability question (Sheldon Ross self test 7.12). I understand everything except the last equality.

My Question: Is the red box equal to the blue box below? Can you show me step by step how to do it? I'm guessing there's some identity that will make it easier...

My Attempt: Unfortunately in lieu of being able to solve the question using math I put it in python and got different results for the red and blue box... but my script could be wrong. Thanks for your help.

n = 5

redBox = 0
for i in range(1,n):
for j in range(i+1,n+1):
redBox += (i-1)*(j-n)
redBox = 2*redBox / ((n-2)**2 * (n-1))

blueBox = 0
for i in range(1,n):
blueBox += (i-1)*(n-i)*(n-i-1)
blueBox = -blueBox / ((n-2)*(n-1)**2)

print(redBox,blueBox)


and for $$n=5$$ I get $$\text{red box} = -0.277$$ vs $$\text{blue box} = -0.20833$$.

Thanks.

Book solution • Crap I made an error with my script... looks like they are equal. Sorry about that. I'm still interested in learning how to solve it though using math. Thanks. – HJ_beginner Sep 24 '18 at 20:29
• Why do you call this a "pre-algebra" question in your title/tags? This is clearly a question about probability/statistics. – Morgan Rodgers Sep 25 '18 at 3:54
• @MorganRodgers Yes it is from a probability word problem. I actually understand all the probability bits of this particular problem, I was confused about how to do the "algebra" for the final equality. Not having a strong foundation for manipulating basic summations and setting up limits of integration has made learning basic probability harder than it has to be... but I am improving... I didn't want to call this an "algebra" problem because I know algebra for people here is not just stuff like $5x=15$ – HJ_beginner Sep 25 '18 at 4:00

## 1 Answer

At a first glance, the sum in the red box looks worse than it is. To get to the blue box you need only to collect common factors and use the formula

• $$\sum_{k=1}^{N}k = \frac{N(N+1)}{2}$$

$$2\sum_{i=1}^{n-1}\sum_{j=i+1}^n \frac{\color{green}{(i-1)}\cdot (j-n)}{\color{blue}{(n-2)(n-1)^2}}= \frac{2}{\color{blue}{(n-2)(n-1)^2}}\sum_{i=1}^{n-1}\color{green}{(i-1)}\boxed{\sum_{j=i+1}^n (j-n)}$$

For the "boxed" sum you may just write down some terms starting with $$j=n$$ to realize that this is nothing but

• $$\boxed{\sum_{j=i+1}^n (j-n)} = -(0+1+\cdots +n - (i+1)) = -\sum_{k=1}^{N}k = -\frac{N(N+1)}{2}$$ with $$N = n-(i+1)=n-i-1$$.

So, $$\boxed{\sum_{j=i+1}^n (j-n) = -\frac{(n-i-1)(n-i)}{2} }$$

Now, just "plug in" the box and rearrange a bit:

$$\frac{\color{blue}{2}}{(n-2)(n-1)^2}\sum_{i=1}^{n-1}(i-1)\boxed{\sum_{j=i+1}^n (j-n)} =$$ $$\frac{\color{blue}{2}}{(n-2)(n-1)^2}\sum_{i=1}^{n-1}(i-1)\left(\color{blue}{-}\frac{(n-i-1)(n-i)}{\color{blue}{2}} \right) =$$ $$\color{blue}{-}\frac{1}{(n-2)(n-1)^2}\sum_{i=1}^{n-1}(i-1)(n-i)(n-i-1)$$

• Thanks for your help - your extra mark ups like colors/boxes make it very clear... fixing $j=n$ and then writing out some of the terms and identifying a familiar pattern is a strategy I will try going forward... I psyched myself out thinking a weird identity was necessary... but one of the few identities I have memorized is the sum of the first consecutive $n$ numbers... again thanks! – HJ_beginner Sep 25 '18 at 3:53
• You are welcome. – trancelocation Sep 25 '18 at 3:55