# How can I calculate the Cumulant-Generating Function in Matlab?

Let $M(h)$ be the moment-generating function, then the cumulant generating function is given by

$$K(h)=\text{ln}M(h)=\\ =\kappa_1h+\frac{1}{2!}h^2\kappa_2+\frac{1}{3!}h^3\kappa_3+\ldots$$ where $\kappa_1, \kappa_2, \ldots$, are the cumulants.

If $L=\sum_{j=1}^Nc_jx_j$ is a function of $N$ independent variables, then the cumulant-generating function for $L$ is given by $$K(h)=\sum_{j=1}^NK_j(c_jh).$$

• You should use the equation environment and latex. Do you know how to calculate the moment generating function $M(h)$ then the cumulant is just $\ln M(h)$ just look at the defintions (or e.g. wikipedia). – Ric Jan 9 '14 at 11:45
• Then for a normal distribution as in M(y)= E(e Aτ(t)) where A= e(βmean+(1/2) β^2*sigma^2) Thus I need to compute the Taylor expansion around the mean (τ (t)) – Shikamekika SK Jan 9 '14 at 11:58
• Please yous latex, I can not read your formula. Whatever: you just take the log that's it! No expansion needed. If you know the moment generating function, then evaluate it and take the log. – Ric Jan 9 '14 at 11:59
• The issue is I did not find any function that allows the evaluation of the moment generating function so I can’ compute the ‘Cumulant moment generating function’ – Shikamekika SK Jan 9 '14 at 12:08
• For the mgf you usually use the analytic expression if it is known. In the case of the normal distribution you write a function yourself (if it is not built in somewhwere in a package). But you really don't need the series expansion. – Ric Jan 9 '14 at 13:05

I am trying to make things clear with this answer. In the case of the normal distribution it holds that the moment generating function (mgf) is given by $$M(h) = \exp(\mu h + \frac12 \sigma^2 h^2),$$ where $\mu$ is the mean and $\sigma^2$ is the variance. Thus the cumulant generating function $C(h)$ which is given by $C(h) = \ln (M(h))$ reduces to $$C(h) = \mu h + \frac12 \sigma^2 h^2.$$ I am sure you can evaluate this in Matlab.