Re: moment generating function for gaussian and lognormal
- To: mathgroup at smc.vnet.net
- Subject: [mg95871] Re: [mg95806] moment generating function for gaussian and lognormal
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 29 Jan 2009 05:51:57 -0500 (EST)
- Reply-to: hanlonr at cox.net
mgfNormal[t_] = CharacteristicFunction[
NormalDistribution[m, s], -I*t]
E^(m*t + (s^2*t^2)/2)
momentNormal[n_] = Assuming[{n > -1},
ExpectedValue[x^n, NormalDistribution[m, s], x]]
(2^(n/2 - 1)*s^(n - 1)*(((-1)^n + 1)*s*Gamma[(n + 1)/2]*
Hypergeometric1F1[(n + 1)/2, 1/2, m^2/(2*s^2)] -
Sqrt[2]*m*((-1)^n - 1)*Gamma[n/2 + 1]*
Hypergeometric1F1[n/2 + 1, 3/2, m^2/(2*s^2)]))/
(E^(m^2/(2*s^2))*Sqrt[Pi])
This simplifies for n even
Simplify[momentNormal[2 n], Element[n, Integers]]
(2^n*s^(2*n)*Gamma[n + 1/2]*Hypergeometric1F1[n + 1/2, 1/2,
m^2/(2*s^2)])/(E^(m^2/(2*s^2))*Sqrt[Pi])
or n odd
Simplify[momentNormal[2 n + 1], Element[n, Integers]]
(m*2^(n + 1)*s^(2*n)*Gamma[n + 3/2]*Hypergeometric1F1[
n + 3/2, 3/2, m^2/(2*s^2)])/(E^(m^2/(2*s^2))*Sqrt[Pi])
checking the moments with the mgf
And @@ Table[Simplify[
momentNormal[n] == (D[mgfNormal[t], {t, n}] /. t -> 0)], {n, 0, 10}]
True
For the LogNormal the moments have a simple form
momentLogNormal[n_] = Assuming[{n > -1},
ExpectedValue[x^n, LogNormalDistribution[m, s], x]]
E^(m*n + (n^2*s^2)/2)
And @@ {momentLogNormal[1] == Mean[LogNormalDistribution[m, s]],
momentLogNormal[2] - momentLogNormal[1]^2 ==
Variance[LogNormalDistribution[m, s]]} // Simplify
True
Bob Hanlon
---- "tarpanelli at libero.it" <tarpanelli at libero.it> wrote:
=============
Hello,
does anyone has a Mathematica module able to define a moment generating
function for gaussian and lognormal distribution and compute the relative
moments,
thanks in advance,
P