Expected value is equal to $\infty$?

50 Views Asked by At

Given the following set: $$ M=\{2^k | k \in\mathbb{N}_{>0}\}=\{2,4,8,16,...\} $$

Now we chose randomly some elements. For this we have to define a distribution: $$ P(m\in M)=m^{-1} $$

As can be seen this is true: $$ P(m\in M)>0 $$ and also: $$ \sum_{m\in M} P(m)=1 $$

It is possible to calculate the expected value: $$ E[M]=\sum_{m\in M} m*P(m)=\sum_{m\in M} m*m^-1=\sum_{m\in M}1=\infty $$

This confuses me a bit. So i implemented a matlab script which choses random numbers from this set with the given distribution:

function k = random_k()
    k = 1;
    while rand(1) >= 0.5
        k = k + 1;
    end
end

num = 2^random_k();
disp(sprintf('Chosen number: %d\n', num));

The values which i get are not too big. And of course they are much smaller than $\infty$. Obviously always a value less than $\infty$ must be returned. The only special case is that $k$ goes to $\infty$, but this seems to be almost impossible if "real" randomness would be used.

What did i do wrong?

Thank you very much

1

There are 1 best solutions below

0
On BEST ANSWER

You did right ! The expectation is indeed $\infty$. Intuitively this is because the probability of getting a really large number (like $2^{1000}$) is decreasing slower than the values themselves are getting larger. So even though it is unlikely to pick a really large number, the value of this large compensate more than its own low probability.

In order to have a finite expectation you would have define probability smaller than $m^{-1}$ to compensate the large numbers !

For example let's take $p(m) = 3/m^2$.

You can check that : $$ \sum_{m\in M} p(m) = 3\; \sum_{i=1}^\infty \frac{1}{(2^i)^2} = 3\; \sum_{i=1}^\infty \frac{1}{4^i} = 1 $$ Then the expectation is : $$ \sum_{m\in M} p(m)\cdot m = 3\; \sum_{i=1}^\infty \frac{1}{4^i} \cdot 2^i = 3\; \sum_{i=1}^\infty \frac{1}{2^i} = 3 < \infty $$