# MGF of inverse discrete random variable

The following question is straightforward to show with Markov's Inequality:

Let $X_n$ be uniformly distributed on the set {1, 2, ..., n}, and let $Y_n = 1/X_n$. Prove that $Y_n \overset{p}{\rightarrow} 0$.

For practice, I also wanted to use MGFs (on the justification $Z_n\overset{p}{\rightarrow} c \iff Z_n \overset{d}{\rightarrow} c$ where $c$ is a constant). It follows that $M_{Y_n}(t) = \frac{1}{n} \sum_{x=1}^n e^{t/x}$, but when I do the limit by hand I get 0. I also get 0 using Mathematica:

Limit[ Sum[  (1/n) Exp[t/x]   , {x, 1, n}], n -> Infinity]
0


Clearly these are both "wrong" because the MGF of a degenerate random variable equal to 0 with probability 1 is "1", and so that must be the "proper" limit.

The MGF has to only exist in a neighborhood of 0 for $t$, and clearly at $t = 0$ the limit is 1 (but not for any specific but arbitrarily small $t$).

My only thoughts are that I have the MGF wrong itself or that there's something subtle happening with the limit of the arithmetic mean of infinite terms close to 1. Any thoughts would be appreciated!

Edit: Adding a note that my Mathematica version is 11.3, primarily for reference if it helps someone in the future.

• Mathematica 9.0.1.0 does not make the same error with the limit. – whuber Jul 28 '18 at 20:46

It looks like the mgf is correct, because by definition

$$M_{Y_n}(t) = E[\exp(t Y_n)] = \sum_{x=1}^n \exp(t / x) \Pr(X_n=x) = \frac{1}{n}\sum_{x=1}^n \exp(t/x).$$

Since $t$ is real, all these terms are positive. The arithmetic-geometric mean inequality implies

$$M_{Y_n}(t) \ge \left(\prod_{x=1}^n \exp(t/x)\right)^{1/n} = \exp\left(t H_n/n\right)$$

where I have written $H_n=1+1/2+\cdots + 1/n$ for the $n^\text{th}$ Harmonic number. As is well known (and easy to show), $H_n/n\to 0$ as $n$ grows large. The continuity of $\exp$ then implies the right hand side of $(*)$ approaches $\exp(t0)=1$ in the limit. That is,

$$\lim_{n\to\infty}M_{Y_n}(t) \ge 1.\tag{*}$$

On the other hand, consider any real $t$ and select an arbitrary $\varepsilon \gt 0.$ For all integers $n \gt |t| / \log(1+\varepsilon),$ $\exp(t/n) \lt 1 + \varepsilon.$ Let $N \ge 1$ be an integer and break the sum for $M_{Y_{N+n}}(t)$ into two parts,

\eqalign{ M_{Y_{N+n}}(t) &= \frac{1}{N+n} \sum_{x=1}^n \exp(t/x) + \frac{1}{N+n} \sum_{x=n+1}^{N+n} \exp(t/x) \\ &= \frac{n}{N+n} M_{Y_n}(t) + \frac{1}{N+n} \sum_{x=n+1}^{N+n} \exp(t/x) \\ &\lt \frac{n}{N+n} M_{Y_n}(t) + \frac{1}{N+n} \sum_{x=n+1}^{N+n}(1+\varepsilon) \\ &= \frac{n}{N+n} M_{Y_n}(t) + \frac{N}{N+n}(1 + \varepsilon). }

As $N$ grows large (still keeping $t,$ $\varepsilon,$ and $n$ fixed), the first term converges to $0$ while the second converges to $1 + \varepsilon,$ establishing

$$\lim_{n\to\infty} M_{Y_n}(t) \le 1 + \varepsilon.\tag{**}$$

Since $\varepsilon$ is arbitrarily small, results $(*)$ and $(**)$ together show the limit of the mgf can only be the unit constant function.