Expected value and variance of a RV that takes values uniformly between [2^a, 2^b]

552 Views Asked by At

Similarly to this question I have a question about the problem:

"Let a and b be positive integers with $a \leq b$, and let $X$ be a random variable that takes as values, with equal probability, the powers of $2$ in the interval $[2^a, 2^b]$. Find the expected value and the variance of X."

I'm aware that $$\mathbb{E}[X] = \sum_{k=a}^{b} \frac{1}{b - a + 1} 2^k = \frac{2^{b+1} - 2^a}{b - a + 1}$$ and I also derived it for myself.

But from the master solution, I don't understand how the second moment $\mathbb{E}[X^2]$ is derived:

$$ \mathbb{E}[X^2] = \sum_{k=a}^{b} \frac{1}{b - a + 1} (2^k)^2 = \frac{4^{b+1} - 4^a}{3(b - a + 1)}$$

Specifically: why do we need to multiply the denominator with 3 instead of just dividing by their differences $b - a + 1$ once? Since we're only squaring the random variable $X$ and there are no terms that rely on the index $k$ in the fraction, we should basically be able to move it out of the sum and just multiply the whole sum with $\frac{1}{b - a + 1}$, i.e: $$ \frac{1}{b - a + 1} \sum_{k=a}^{b}(2^k)^2 $$

So I was hoping someone could enlighten me on where that multiplicative factor comes from!

2

There are 2 best solutions below

4
On BEST ANSWER

Recalling the identity $$1+x+x^2+\cdots+x^n=\frac{x^{n+1}-1}{x-1}$$ and noting that $(2^k)^2=4^k$, we get \begin{align*} &\sum_{k=a}^{b}(2^k)^2\\[4pt] =\;&\sum_{k=a}^{b}4^k\\[4pt] =\;&4^a\sum_{k=0}^{b-a}4^k\\[4pt] =\;&4^a\left(\frac{4^{b-a+1}-1}{4-1}\right)\\[4pt] =\;&\frac{4^{b+1}-4^a}{3}\\[4pt] \end{align*}

0
On

Moving $\frac1{b-a+1}$ out of the sum is correct. Now rewrite $(2^k)^2$ as $4^k$ and view the sum as a number in base $4$: $$\sum_{k=a}^b4^k=111\dots111000\dots000$$ with $b+1$ total digits and $a$ zeros. This suggests $4^{b+1}-4^a$ as a closed form, but $$4^{b+1}-4^a=333\dots333000\dots000$$ which is the previous sum multiplied by $3$. So the division by $3$ comes in here.