Skip to main content
On this page

The von Mises–Fisher Distribution

A mathematical introduction to directional data, Bessel-function asymptotics, and stable normalization on the hypersphere.

Directional data arise whenever orientation matters more than magnitude. A wind direction, a point on the globe, and a normalized embedding are all unit vectors: their lengths have been fixed, so the information lies in where they point. This is especially useful in high dimensions—for example, with normalized LLM embeddings—where magnitude may be sensitive to scale or preprocessing, while direction can capture semantic similarity.

The von Mises–Fisher distribution, usually abbreviated vMF, is a natural model for such data. It plays a role on the sphere similar to that of an isotropic Gaussian in Euclidean space: one parameter specifies the preferred direction, and another controls how tightly observations gather around it.

This post develops the density, its normalization constant, the relevant Bessel-function asymptotics, and a numerically stable way to evaluate the log density.

1. Geometry and Density

Let

Sp1={xRp:x=1}\mathbb{S}^{p-1} = \left\{\mathbf{x}\in\mathbb{R}^p:\lVert\mathbf{x}\rVert=1\right\}

be the unit sphere in pp-dimensional Euclidean space. The sphere itself has dimension p1p-1: for example, S1\mathbb{S}^1 is the unit circle and S2\mathbb{S}^2 is the familiar sphere in three-dimensional space.

For xSp1\mathbf{x}\in\mathbb{S}^{p-1}, the vMF density with mean direction μSp1\boldsymbol{\mu}\in\mathbb{S}^{p-1} and concentration κ0\kappa\geq 0 is

f(xμ,κ)=Cp(κ)exp ⁣(κμx).f(\mathbf{x}\mid\boldsymbol{\mu},\kappa) = C_p(\kappa)\exp\!\left(\kappa\boldsymbol{\mu}^{\top}\mathbf{x}\right).

Because both vectors have unit length,

μx=cosθ,\boldsymbol{\mu}^{\top}\mathbf{x}=\cos\theta,

where θ\theta is the angle between them. The density is therefore proportional to exp(κcosθ)\exp(\kappa\cos\theta). This gives the two parameters a direct geometric interpretation:

  • μ\boldsymbol{\mu} points toward the mode of the distribution.
  • κ\kappa controls angular concentration. At κ=0\kappa=0, every direction is equally likely; as κ\kappa grows, the density becomes more concentrated around μ\boldsymbol{\mu}.

For κ>0\kappa>0, the normalization constant is

Cp(κ)=κp/21(2π)p/2Ip/21(κ),C_p(\kappa) = \frac{\kappa^{p/2-1}} {(2\pi)^{p/2}I_{p/2-1}(\kappa)},

where IνI_\nu is the modified Bessel function of the first kind of order ν\nu. At κ=0\kappa=0, Cp(0)C_p(0) is defined by its continuous limit, derived in the small-concentration section below. This constant is the technically difficult part of the density: it makes the density integrate to one, but it also requires care when κ\kappa is very small or very large.

2. Why the Bessel Function Matters

Let

ν=p21.\nu=\frac{p}{2}-1.

The modified Bessel function of the first kind has the series expansion

Iν(κ)=m=01m!Γ(m+ν+1)(κ2)2m+ν.I_\nu(\kappa) = \sum_{m=0}^{\infty} \frac{1}{m!\,\Gamma(m+\nu+1)} \left(\frac{\kappa}{2}\right)^{2m+\nu}.

The Bessel function appears because normalizing the vMF density requires integrating an exponential of cosine similarity over an entire sphere. For computation, the important point is not the full series itself but how it behaves at the two extremes of κ\kappa.

Small Concentration: κ0\kappa\to 0

When κ\kappa is small, the first term of the series dominates:

Iν(κ)1Γ(ν+1)(κ2)ν=κν2νΓ(p/2).I_\nu(\kappa) \sim \frac{1}{\Gamma(\nu+1)} \left(\frac{\kappa}{2}\right)^\nu = \frac{\kappa^\nu}{2^\nu\Gamma(p/2)}.

Substituting this approximation into the normalization constant gives

Cp(κ)Γ(p/2)2πp/2=1Sp1,C_p(\kappa) \longrightarrow \frac{\Gamma(p/2)}{2\pi^{p/2}} = \frac{1}{S_{p-1}},

where

Sp1=2πp/2Γ(p/2)S_{p-1}=\frac{2\pi^{p/2}}{\Gamma(p/2)}

is the surface area of Sp1\mathbb{S}^{p-1}. Since exp(κμx)1\exp(\kappa\boldsymbol{\mu}^{\top}\mathbf{x})\to 1 as well,

f(xμ,κ)1Sp1.f(\mathbf{x}\mid\boldsymbol{\mu},\kappa) \longrightarrow \frac{1}{S_{p-1}}.

Thus, the vMF distribution converges to the uniform distribution on the sphere. Intuitively, when κ\kappa vanishes, the model loses its preferred direction.

Large Concentration: κ\kappa\to\infty

For fixed ν\nu and large κ\kappa,

Iν(κ)eκ2πκ(14ν218κ+O(κ2)).I_\nu(\kappa) \sim \frac{e^\kappa}{\sqrt{2\pi\kappa}} \left( 1-\frac{4\nu^2-1}{8\kappa} +O(\kappa^{-2}) \right).

This exponential growth explains why direct numerical evaluation can overflow. It also reveals the local shape of the vMF density. Near the mean direction, θ\theta is small, so

cosθ1θ22eκcosθeκeκθ2/2.\cos\theta\approx 1-\frac{\theta^2}{2} \qquad\Longrightarrow\qquad e^{\kappa\cos\theta} \approx e^\kappa e^{-\kappa\theta^2/2}.

Locally, the angular deviation therefore looks Gaussian, with a typical scale of order κ1/2\kappa^{-1/2}. Large κ\kappa means a narrow cap around μ\boldsymbol{\mu}.

Scientific libraries commonly avoid the overflow in Iν(κ)I_\nu(\kappa) by evaluating the scaled Bessel function

Iνsc(κ)=eκIν(κ),I_\nu^{\mathrm{sc}}(\kappa) = e^{-\kappa}I_\nu(\kappa),

which remains representable even when Iν(κ)I_\nu(\kappa) itself is enormous. Its large-κ\kappa behavior is

Iνsc(κ)12πκ(14ν218κ+O(κ2)).I_\nu^{\mathrm{sc}}(\kappa) \sim \frac{1}{\sqrt{2\pi\kappa}} \left( 1-\frac{4\nu^2-1}{8\kappa} +O(\kappa^{-2}) \right).

3. The Log-Normalization Constant

Probability calculations are usually performed in log space. With ν=p/21\nu=p/2-1,

logCp(κ)=νlogκp2log(2π)logIν(κ).\log C_p(\kappa) = \nu\log\kappa -\frac{p}{2}\log(2\pi) -\log I_\nu(\kappa).

For large κ\kappa, use

logIν(κ)=κ+logIνsc(κ)\log I_\nu(\kappa) = \kappa+\log I_\nu^{\mathrm{sc}}(\kappa)

to obtain the stable expression

logCp(κ)=νlogκp2log(2π)κlogIνsc(κ).\log C_p(\kappa) = \nu\log\kappa -\frac{p}{2}\log(2\pi) -\kappa -\log I_\nu^{\mathrm{sc}}(\kappa).

At very small κ\kappa, the terms νlogκ\nu\log\kappa and logIν(κ)\log I_\nu(\kappa) both become problematic even though their difference has a finite limit. In that regime, use

logCp(0)=logΓ(p/2)log2p2logπ,\log C_p(0) = \log\Gamma(p/2)-\log 2-\frac{p}{2}\log\pi,

or a small-κ\kappa expansion around it. The two regimes address different numerical failures: the small-κ\kappa formula avoids cancellation and undefined logarithms, while the scaled Bessel function prevents overflow at large κ\kappa.

4. Deriving the Normalization Constant

It remains to show why the stated Cp(κ)C_p(\kappa) is correct. Define the unnormalized integral

Zp(κ)=Sp1exp ⁣(κμx)dσ(x).Z_p(\kappa) = \int_{\mathbb{S}^{p-1}} \exp\!\left(\kappa\boldsymbol{\mu}^{\top}\mathbf{x}\right) \,\mathrm{d}\sigma(\mathbf{x}).

Rotational symmetry allows us to align μ\boldsymbol{\mu} with the first coordinate axis. Writing x1=cosθx_1=\cos\theta, the remaining coordinates form a copy of Sp2\mathbb{S}^{p-2}, and the surface element contributes sinp2θ\sin^{p-2}\theta. Hence

Zp(κ)=Sp20πeκcosθsinp2θdθ,Z_p(\kappa) = S_{p-2} \int_0^\pi e^{\kappa\cos\theta} \sin^{p-2}\theta \,\mathrm{d}\theta,

where

Sp2=2π(p1)/2Γ((p1)/2).S_{p-2} = \frac{2\pi^{(p-1)/2}} {\Gamma((p-1)/2)}.

The modified Bessel function has the integral representation

Iν(z)=(z/2)νπΓ(ν+1/2)0πezcosθsin2νθdθ.I_\nu(z) = \frac{(z/2)^\nu} {\sqrt{\pi}\,\Gamma(\nu+1/2)} \int_0^\pi e^{z\cos\theta} \sin^{2\nu}\theta \,\mathrm{d}\theta.

Set ν=p/21\nu=p/2-1, so that 2ν=p22\nu=p-2. Rearranging the integral representation and substituting the sphere area gives

Zp(κ)=Sp2πΓ ⁣(p12)(2κ)p/21Ip/21(κ)=(2π)p/2κ1p/2Ip/21(κ).\begin{aligned} Z_p(\kappa) &= S_{p-2}\sqrt{\pi}\, \Gamma\!\left(\frac{p-1}{2}\right) \left(\frac{2}{\kappa}\right)^{p/2-1} I_{p/2-1}(\kappa)\\ &= (2\pi)^{p/2} \kappa^{1-p/2} I_{p/2-1}(\kappa). \end{aligned}

Therefore

Cp(κ)=Zp(κ)1=κp/21(2π)p/2Ip/21(κ),C_p(\kappa) = Z_p(\kappa)^{-1} = \frac{\kappa^{p/2-1}} {(2\pi)^{p/2}I_{p/2-1}(\kappa)},

which is the required normalization constant.

5. The Main Picture

The vMF distribution is built from a simple geometric score, μx=cosθ\boldsymbol{\mu}^{\top}\mathbf{x}=\cos\theta, and a nontrivial normalization constant. The geometry explains the model: μ\boldsymbol{\mu} chooses a direction and κ\kappa controls angular spread. The Bessel function supplies the exact normalization, its asymptotics recover the uniform and highly concentrated limits, and its scaled form makes the density practical to evaluate numerically.