6
$\begingroup$

I am having trouble generating moments from the moment generating function of the uniform.

By the definition of M.G.F, we can calculate: $$ M(t) = \begin{cases} \frac{e^{tb} - e^{ta}}{tb-ta} : t \ne 0 \\ 1 : t=0 \end{cases} $$

However, generating moments involves taking the nth derivative and then setting t=0. If I take the derivative of the $t \ne 0$ case, the derivative is not defined when $t=0$; if I take the derivative of the $t=0$ case, the derivative is 0. The mgf is not generating moments for uniform distribution.

$\endgroup$
1
  • 2
    $\begingroup$ The derivative is defined at $t=0$, just apply L'Hopitals rule in the definition of the derivative. $\endgroup$
    – user266286
    Commented Mar 29, 2022 at 15:11

2 Answers 2

10
$\begingroup$

As you say, the derivatives of $M(t)$ are not defined at $t=0$.

For $t\ne 0$, the first derivative for example is $$M'(t)=\frac{1}{t^2(b-a)}\left[e^{tb}(tb-1)-e^{ta}(ta-1)\right]$$

But note that $M'(t)\to \frac{a+b}{2}$ as $t\to 0$, so $M'(t)$ has a removable discontinuity at $t=0$.

So just like $M(t)$ itself, we define

$$M'(t)=\begin{cases} \frac{1}{t^2(b-a)}\left[e^{tb}(tb-1)-e^{ta}(ta-1)\right]&,\text{ if }t\ne 0 \\\frac{a+b}{2}&,\text{ if }t=0 \end{cases}$$

Hence the first moment is given by $$E[X]=M'(0)=\lim_{t\to 0}M'(t)$$

If you do this from definition, you will end up with the same result:

$$M'(0)=\lim_{t\to 0}\frac1t \left[M(t)-M(0)\right]=\frac{a+b}{2}$$

We define the $r$th order derivative $M^{(r)}(t)$ similarly so that it is continuous at $0$.

And the $r$th order moment of $X$ for $r\in \mathbb N$ is given by

$$E[X^r]=M^{(r)}(0)=\lim_{t\to 0}M^{(r)}(t)$$

$\endgroup$
3
  • $\begingroup$ Hello @StubbornAtom can you give a look at my question please? math.stackexchange.com/questions/4299534/… $\endgroup$ Commented Nov 8, 2021 at 10:50
  • $\begingroup$ @GennaroArguzzi Check the answer by whuber. You need not find derivatives and their limits to find the moments from mgf. $\endgroup$ Commented Nov 8, 2021 at 14:38
  • $\begingroup$ The derivatives are defined at $t=0.$ They just aren't computable by applying the usual rules of differentiation. $\endgroup$
    – whuber
    Commented Aug 31 at 13:42
7
$\begingroup$

The numerator is an entire function, which means you can expand it as a Taylor series around any point you like, it will converge absolutely, and you can compute with this (infinite) sum term by term. Since for any $z,$

$$e^z = 1 + \frac{z}{1!} + \frac{z^2}{2!} + \cdots = \sum_{n=0}^\infty \frac{z^n}{n!},$$

compute the Taylor series of the numerator term by term. Since the first term is always $1,$ the first term of the difference is $1-1=0,$ allowing us to begin the sum at $n=1$ instead of $n=0.$ You will quickly notice that every term in the difference is a multiple of $bt-at,$ so we may factor this out:

$$\eqalign{ e^{bt} - e^{at} &= \sum_{n=0}^\infty \left(\frac{(bt)^n}{n!} - \frac{(at)^n}{n!}\right)\\ &= \sum_{n=1}^\infty \frac{(bt)^n-(at)^n}{n!} \\ &= \sum_{n=1}^\infty (bt-at) \frac{(b^{n-1}+b^{n-2}a + \cdots + b a^{n-2} + a^{n-1})t^{n-1}}{n!} \\ &= (bt-at)\sum_{n=1}^\infty \frac{(b^{n-1}+b^{n-2}a + \cdots + b a^{n-2} + a^{n-1})t^{n-1}}{n!}. }$$

Therefore $M$ is uniquely defined at $0$ as $M(0)=\lim_{z\to 0}M(z)$ and that limit takes no work at all to compute because

$$M(t) = \frac{e^{bt}-e^{at}}{bt - at} = \sum_{n=1}^\infty \frac{(b^{n-1}+b^{n-2}a + \cdots + b a^{n-2} + a^{n-1})t^{n-1}}{n!} = \sum_{n=0}^\infty \frac{(b^{n+1}-a^{n+1})}{(b-a)(n+1)}\frac{t^n}{n!}$$

also is an entire function (even in the case $b=a,$ by the way). You can read the $n^\text{th}$ moment directly off the last expression because it is the coefficient of $t^n/n!,$ given by

$$\mu_n = \frac{b^{n+1}-a^{n+1}}{(b-a)(n+1)}.$$

Although technically we did take a limit, we did not have to compute it, and neither did we need to compute any derivatives. (The expansion of $e^z$ is the definition of the exponential function: see Walter Rudin, Real and Complex Analysis, 1986.)


Let's check. The first few of these moments are

$$\mu_0 = 1;\ \mu_1 = \frac{b^2-a^2}{2(b-a)} = \frac{a+b}{2};\ \mu_2 = \frac{b^3-a^3}{3(b-a)} = \frac{b^2+ab+a^2}{3}.$$

We can easily compute these from the corresponding (raw) moments of a Uniform$(0,1)$ distribution, which are $1,$ $1/2,$ and $1/3,$ respectively, because when a variable with probability element $f(x)\mathrm{d}x$ is scaled by a factor $\sigma,$ $\mu_n$ is multiplied by $\sigma^n$ and when a variable is shifted by an amount $a$ the new moment is given by the Binomial Theorem as

$$\int_{\mathbb{R}} (x+a)^nf(x)\,\mathrm{d}x = \sum_{i=0}^n \binom{n}{i}a^{n-i}\,\int_{\mathbb{R}} x^if(x)\,\mathrm{d}x = \sum_{i=0}^n \binom{n}{i}a^{n-i}\mu_i.$$

Thus, scaling by $\sigma=b-a$ and shifting by $a$ gives

$$\eqalign{ \mu_0 &= 1\\ \mu_1 &= a(b-a)^0\mu_0 + (b-a)^1\mu_1 = a(1)+\frac{b-a}{2} = \frac{a+b}{2}\\ \mu_2 &= a^2(b-a)^0\mu_0 + 2a(b-a)^1\mu_1 + (b-a)^2\mu_2 = a^2(1) + \frac{2a(b-a)}{2} + \frac{(b-a)^2}{3} \\ &= \frac{b^2+ab+a^2}{3}, }$$

confirming the expressions given by $M.$ You can see how the calculations for higher moments are going to involve algebraic simplification of ever more complicated polynomials: the moment generating function approach spared us that work.

$\endgroup$
1
  • 1
    $\begingroup$ (+1) I guess I should have emphasized that we need not compute derivatives and take their limits to find moments from the MGF. $\endgroup$ Commented Feb 23, 2020 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.