Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

EM for generalized hyperbolic distributions

Expectation–maximization fits a latent-variable model by alternating posterior expectations and complete-data likelihood maximization. The general method is due to Dempster, Laird, and Rubin, 1977, Maximum likelihood from incomplete data via the EM algorithm. This GH specialization follows the upstream derivation, which credits Hu (2005), Calibration of multivariate generalized hyperbolic distributions using the EM algorithm.

Read ordinary EM for the likelihood inequality, and GH for the joint density and parameter conventions. We treat independent observations x1,,xnRdx_1,\ldots,x_n\in\mathbb R^d, with positive-definite Σ\Sigma and interior GIG parameters a,b>0a,b>0, unless a boundary case is stated.

Complete and observed data

Write the classical parameter tuple as ϑ=(μ,γ,Σ,p,a,b)\vartheta=(\mu,\gamma,\Sigma,p,a,b); reserve θ\theta for the joint family’s natural coordinates. The model is

X=μ+γY+YLZ,YGIG(p,a,b),ZNd(0,Id),YZ,LL=Σ.\begin{aligned} X&=\mu+\gamma Y+\sqrt Y\,LZ,\\ Y&\sim\operatorname{GIG}(p,a,b),\qquad Z\sim\mathcal N_d(0,I_d),\\ Y&\perp Z,\qquad LL^\top=\Sigma. \end{aligned}

For d=1d=1, the conditioning note uses W=YW=Y, β=γ\beta=\gamma, and σ2=Σ\sigma^2=\Sigma. The observed likelihood uses fX(x;ϑ)=f(x,y;ϑ)dyf_X(x;\vartheta)=\int f(x,y;\vartheta)\,dy. The joint GH law is an exponential family, which makes its expected log likelihood easier to optimize.

Conditional distribution of the mixing variable

Expanding the normal quadratic in the joint density and collecting powers of yy gives

f(yx;ϑ)yp1d/2exp ⁣[12{(a+γΣ1γ)y+(b+(xμ)Σ1(xμ))/y}].f(y\mid x;\vartheta)\propto y^{p-1-d/2} \exp\!\left[-\tfrac12\left\{ \bigl(a+\gamma^\top\Sigma^{-1}\gamma\bigr)y +\bigl(b+(x-\mu)^\top\Sigma^{-1}(x-\mu)\bigr)/y\right\}\right].

Set r=pd/2r=p-d/2, A=a+γΣ1γA=a+\gamma^\top\Sigma^{-1}\gamma, and B(x)=b+(xμ)Σ1(xμ)B(x)=b+(x-\mu)^\top\Sigma^{-1}(x-\mu). All are evaluated at the current iterate when used in an E-step. Then

YX=x;ϑGIG(r,A,B(x)).Y\mid X=x;\vartheta\sim\operatorname{GIG}(r,A,B(x)).

Interior assumptions guarantee A,B(x)>0A,B(x)>0 for every observation. The GIG normalizing integral therefore supplies every real posterior power moment:

Eϑ[YsX=x]=(B(x)A)s/2Kr+s(AB(x))Kr(AB(x)).\mathbb E_\vartheta[Y^s\mid X=x] =\left(\frac{B(x)}{A}\right)^{s/2} \frac{K_{r+s}(\sqrt{AB(x)})}{K_r(\sqrt{AB(x)})}.

Differentiating at s=0s=0 yields

Eϑ[logYX=x]=12log(B(x)/A)+νlogKν(AB(x))ν=r.\mathbb E_\vartheta[\log Y\mid X=x] =\tfrac12\log(B(x)/A) +\left.\partial_\nu\log K_\nu(\sqrt{AB(x)})\right|_{\nu=r}.

The three expectations of YY, Y1Y^{-1}, and logY\log Y must be evaluated separately. Replacing YY by its posterior mean inside nonlinear statistics would give a different algorithm.

E-step in one statistic order

Use the joint sufficient-statistic blocks t(x,y)=(logy,y1,y,x,x/y,xx/y)t(x,y)=(\log y,y^{-1},y,x,x/y,xx^\top/y), as in the GIG and GH notes. At iterate ϑk\vartheta_k let

uj=Ek[Y1xj],vj=Ek[Yxj],lj=Ek[logYxj].u_j=\mathbb E_k[Y^{-1}\mid x_j],\qquad v_j=\mathbb E_k[Y\mid x_j],\qquad l_j=\mathbb E_k[\log Y\mid x_j].

The E-step averages all six blocks:

η^1(k)=n1jlj,η^2(k)=n1juj,η^3(k)=n1jvj,η^4(k)=n1jxj,η^5(k)=n1jxjuj,η^6(k)=n1jxjxjuj.\begin{aligned} \widehat\eta_1^{(k)}&=n^{-1}\sum_j l_j,& \widehat\eta_2^{(k)}&=n^{-1}\sum_j u_j,& \widehat\eta_3^{(k)}&=n^{-1}\sum_j v_j,\\ \widehat\eta_4^{(k)}&=n^{-1}\sum_j x_j,\\ \widehat\eta_5^{(k)}&=n^{-1}\sum_j x_j u_j,\\ \widehat\eta_6^{(k)}&=n^{-1}\sum_j x_jx_j^\top u_j. \end{aligned}

The source EM note uses the first three slots in a different order. Here η^1\widehat\eta_1 always means the log moment, η^2\widehat\eta_2 the inverse moment, and η^3\widehat\eta_3 the first moment. This order also governs the mixture architecture.

M-step as an expectation-to-parameter map

Holding the old posterior fixed, maximize

Q(ϑϑk)=1njEk[logf(xj,Y;ϑ)X=xj].Q(\vartheta\mid\vartheta_k) =\frac1n\sum_j\mathbb E_k[\log f(x_j,Y;\vartheta)\mid X=x_j].

In natural coordinates this equals θ,η^(k)ψ(θ)\langle\theta,\widehat\eta^{(k)}\rangle-\psi(\theta) plus a constant. For an attained interior maximum of the full joint family, the new model matches the posterior sufficient-statistic averages. Suppressing (k)(k) on η^\widehat\eta, the normal-block update is

μk+1=η^4η^3η^51η^2η^3,γk+1=η^5η^2η^41η^2η^3,Σk+1=η^6η^5μk+1μk+1η^5+η^2μk+1μk+1η^3γk+1γk+1,(pk+1,ak+1,bk+1)=arg maxp,a,bLGIG(p,a,bη^1,η^2,η^3).\begin{aligned} \mu_{k+1}&=\frac{\widehat\eta_4-\widehat\eta_3\widehat\eta_5} {1-\widehat\eta_2\widehat\eta_3},\\ \gamma_{k+1}&=\frac{\widehat\eta_5-\widehat\eta_2\widehat\eta_4} {1-\widehat\eta_2\widehat\eta_3},\\ \Sigma_{k+1}&=\widehat\eta_6-\widehat\eta_5\mu_{k+1}^\top -\mu_{k+1}\widehat\eta_5^\top +\widehat\eta_2\mu_{k+1}\mu_{k+1}^\top -\widehat\eta_3\gamma_{k+1}\gamma_{k+1}^\top,\\ (p_{k+1},a_{k+1},b_{k+1})&=\operatorname*{arg\,max}_{p,a,b} L_{\mathrm{GIG}}(p,a,b\mid\widehat\eta_1,\widehat\eta_2,\widehat\eta_3). \end{aligned}

The two vector updates solve η^4=μ+γη^3\widehat\eta_4=\mu+\gamma\widehat\eta_3 and η^5=μη^2+γ\widehat\eta_5=\mu\widehat\eta_2+\gamma. The covariance formula then follows from the sixth joint moment. The last line is the GIG likelihood problem; it usually requires numerical optimization. Only the normal block is closed form in the general GH case.

These formulas require a nonzero denominator, a positive-definite recovered covariance, and a feasible attained mixing-law optimum. Positive-definiteness can fail with insufficiently varied data. Convexity of the GIG subproblem does not remove its domain constraints or numerical conditioning problems.

With exact posteriors and an M-step that increases QQ, the EM likelihood inequality ensures

(ϑk+1)(ϑk),(ϑ)=n1jlogfX(xj;ϑ).\ell(\vartheta_{k+1})\geq\ell(\vartheta_k),\qquad \ell(\vartheta)=n^{-1}\sum_j\log f_X(x_j;\vartheta).

This concerns the observed likelihood. It does not guarantee a global MLE, a unique stationary point, convergence of the parameter sequence, or a particular speed. Approximate numerical steps should be checked against their actual objective.

Scale normalization and equivariance

The GH scale action is

Tcϑ=(μ,γ/c,Σ/c,p,a/c,bc),c>0.T_c\vartheta=(\mu,\gamma/c,\Sigma/c,p,a/c,bc),\qquad c>0.

It represents the same observed law by replacing YY with Y=cYY'=cY. The posterior parameters become (r,A/c,cB(x))(r,A/c,cB(x)). Consequently,

ETcϑ[Ysx]=csEϑ[Ysx],ETcϑ[logYx]=Eϑ[logYx]+logc.\begin{aligned} \mathbb E_{T_c\vartheta}[Y^s\mid x] &=c^s\mathbb E_\vartheta[Y^s\mid x],\\ \mathbb E_{T_c\vartheta}[\log Y\mid x] &=\mathbb E_\vartheta[\log Y\mid x]+\log c. \end{aligned}

The E-step output transforms as

(η^1,η^2,η^3,η^4,η^5,η^6)(η^1+logc,η^2/c,cη^3,η^4,η^5/c,η^6/c).(\widehat\eta_1,\widehat\eta_2,\widehat\eta_3, \widehat\eta_4,\widehat\eta_5,\widehat\eta_6) \longmapsto (\widehat\eta_1+\log c,\widehat\eta_2/c,c\widehat\eta_3, \widehat\eta_4,\widehat\eta_5/c,\widehat\eta_6/c).

Substitution in (9), including the rescaled GIG optimum, proves F(Tcϑ)=TcF(ϑ)F(T_c\vartheta)=T_cF(\vartheta) for the exact unconstrained EM map FF when the maximizers are unique (or selected consistently under scaling).

To impose Σ=1|\Sigma|=1 after an update, choose c=Σ1/dc=|\Sigma|^{1/d} and transform all coupled parameters:

(μ,γ,Σ,p,a,b)(μ,Σ1/dγ,Σ1/dΣ,p,Σ1/da,Σ1/db).(\mu,\gamma,\Sigma,p,a,b)\longmapsto (\mu,|\Sigma|^{-1/d}\gamma,|\Sigma|^{-1/d}\Sigma, p,|\Sigma|^{-1/d}a,|\Sigma|^{1/d}b).

The observed density and its likelihood are unchanged. This is a choice of scale representative, not a penalty or a guarantee of numerical stability. Fixed bounds, shrinkage, approximate solvers, or inconsistent choices among maximizers can break the exact equivariance argument.

ECM and multiple cycles

Meng and Rubin’s 1993 ECM framework replaces one M-step by conditional maximizations of parameter blocks. The upstream note discusses its multi-cycle version (MCECM) for GH, also citing McNeil, Frey, and Embrechts, Quantitative Risk Management (2010). A two-cycle construction in the unconstrained redundant coordinates is:

  1. Compute the posterior moments at ϑk\vartheta_k, then maximize the normal block (μ,γ,Σ)(\mu,\gamma,\Sigma) with (p,a,b)(p,a,b) fixed.

  2. Recompute the posterior moments at this intermediate parameter and maximize the GIG block with the new normal block fixed.

Each conditional maximization must increase the corresponding current QQ. A full coupled scale normalization can then be applied without changing the observed law. If instead one imposes a determinant constraint inside a conditional maximization while holding the mixing parameters fixed, that is a constrained optimization problem: simply normalizing the unconstrained covariance is not a justification for its ascent property.

EM and valid MCECM updates share the likelihood-ascent argument. Neither has a general guarantee of reaching the global MLE, and their numerical costs and convergence rates depend on the problem.

Special mixing families

Write l=E[logY]l=\mathbb E[\log Y], u=E[Y1]u=\mathbb E[Y^{-1}], and v=E[Y]v=\mathbb E[Y] for the posterior averages at the relevant E-step. Denote the digamma function by ψ0\psi_0 and its derivative by ψ1\psi_1, to distinguish them from the log-partition ψ\psi.

Gamma mixing: variance gamma

For YGamma(α,ρ)Y\sim\operatorname{Gamma}(\alpha,\rho) with rate ρ\rho, E[logY]=ψ0(α)logρ\mathbb E[\log Y]=\psi_0(\alpha)-\log\rho and E[Y]=α/ρ\mathbb E[Y]=\alpha/\rho. The mixing-law update solves

ψ0(α)logα=llogv,ρ=α/v.\psi_0(\alpha)-\log\alpha=l-\log v,\qquad \rho=\alpha/v.

A Newton proposal is

αt+1=αtψ0(αt)logαtl+logvψ1(αt)1/αt.\alpha_{t+1}=\alpha_t- \frac{\psi_0(\alpha_t)-\log\alpha_t-l+\log v} {\psi_1(\alpha_t)-1/\alpha_t}.

Safeguards must keep α>0\alpha>0 and verify improvement. The posterior is GIG with r=αd/2r=\alpha-d/2, A=2ρ+γΣ1γA=2\rho+\gamma^\top\Sigma^{-1}\gamma, and B=q(x)B=q(x). At x=μx=\mu, B=0B=0; posterior propriety and required inverse moments then need separate checking. For example, this gamma posterior has finite inverse moment only if r>1r>1. The interior GIG formula does not cover that point without a boundary analysis.

Inverse-Gaussian mixing: NIG

For an inverse Gaussian with mean mm and shape λ\lambda, E[Y]=m\mathbb E[Y]=m and E[Y1]=1/m+1/λ\mathbb E[Y^{-1}]=1/m+1/\lambda. The closed-form mixing update is

m=v,λ=1u1/v.m=v,\qquad \lambda=\frac{1}{u-1/v}.

It requires uv>1uv>1; equality is a constant-mixing limit. Its GIG embedding has p=1/2p=-1/2, a=λ/m2a=\lambda/m^2, b=λb=\lambda. The posterior is generally GIG with order 1/2d/2-1/2-d/2, rather than another inverse Gaussian.

Inverse-gamma mixing

For YInvGamma(α,ρ)Y\sim\operatorname{InvGamma}(\alpha,\rho), E[logY]=logρψ0(α)\mathbb E[\log Y]=\log\rho-\psi_0(\alpha) and E[Y1]=α/ρ\mathbb E[Y^{-1}]=\alpha/\rho. Hence

logαψ0(α)=l+logu,ρ=α/u,\log\alpha-\psi_0(\alpha)=l+\log u,\qquad \rho=\alpha/u,

with Newton proposal

αt+1=αtlogαtψ0(αt)llogu1/αtψ1(αt).\alpha_{t+1}=\alpha_t- \frac{\log\alpha_t-\psi_0(\alpha_t)-l-\log u} {1/\alpha_t-\psi_1(\alpha_t)}.

This is again a scalar solve, not a general closed-form shape estimate. For γ=0\gamma=0 the posterior has A=0A=0 and is inverse gamma with shape α+d/2\alpha+d/2; a finite posterior first moment requires α+d/2>1\alpha+d/2>1 when that moment is needed. Symmetry-constrained updates can require fewer statistics than the full variance–mean model.

Marginal familyMixing statistics to fit its free parametersMixing M-step
General GH(logy,y1,y)(\log y,y^{-1},y)Three-parameter convex problem in natural coordinates
Variance gamma(logy,y)(\log y,y)Scalar shape solve and rate recovery
NIG(y1,y)(y^{-1},y)Closed form
Normal-inverse gamma(logy,y1)(\log y,y^{-1})Scalar shape solve and scale recovery

The normal block still uses inverse and first posterior moments when both location and mean coupling are free. Reducing the mixing-law statistics does not automatically eliminate these normal-block requirements.

Numerical considerations and implementation

Large pd/2|p-d/2| or extreme AB(x)\sqrt{AB(x)} can overflow or underflow direct Bessel evaluations. Ratios, log-space evaluation, and stable order derivatives matter. The covariance update can suffer cancellation or rank deficiency; determinant normalization does not repair its condition number. Penalties change the optimization objective and need their own ascent analysis.

See why not gradient descent for the optimization comparison and exponential-family core for the expectation-to-natural map. Runnable fitters remain in the upstream EM guide and package API. Continue with online EM, penalized shrinkage, and the mathematical EM framework. The full EM design and Bessel/solver design remain upstream implementation references.

Source and adaptation

Adapted from xshi19/normix, docs/theory/em_algorithm.md, at revision 763bb3608920661a012cf089888d349fbf680aad (2026-09-13 import). Copyright (c) 2020 xshi19. Licensed under MIT. The pinned source records the original version. Notation, mathematical qualifications, and links were adapted for this site; API recipes, executable package cells, and notebook plots are omitted. No upstream benchmark execution or formal-proof verification is claimed for this adaptation.

MIT permission notice

MIT License

Copyright (c) 2020 xshi19

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.