Von Mises–Fisher distribution explained

In directional statistics, the von Mises–Fisher distribution (named after Richard von Mises and Ronald Fisher), is a probability distribution on the

(p-1)

-sphere in

Rp

. If

p=2

the distribution reduces to the von Mises distribution on the circle.

Definition

The probability density function of the von Mises–Fisher distribution for the random p-dimensional unit vector

x

is given by:

fp(x;\boldsymbol{\mu},\kappa)=Cp(\kappa)\exp\left({\kappa\boldsymbol{\mu}Tx}\right),

where

\kappa\ge0,\left\Vert\boldsymbol{\mu}\right\Vert=1

and the normalization constant

Cp(\kappa)

is equal to

Cp(\kappa)=

\kappap/2-1
(2\pi)p/2Ip/2-1(\kappa)

,

where

Iv

denotes the modified Bessel function of the first kind at order

v

. If

p=3

, the normalization constant reduces to

C3(\kappa)=

\kappa
4\pi\sinh\kappa

=

\kappa
2\pi(e\kappa-e-\kappa)

.

The parameters

\boldsymbol{\mu}

and

\kappa

are called the mean direction and concentration parameter, respectively. The greater the value of

\kappa

, the higher the concentration of the distribution around the mean direction

\boldsymbol{\mu}

. The distribution is unimodal for

\kappa>0

, and is uniform on the sphere for

\kappa=0

.

The von Mises–Fisher distribution for

p=3

is also called the Fisher distribution.[1] [2] It was first used to model the interaction of electric dipoles in an electric field.[3] Other applications are found in geology, bioinformatics, and text mining.

Note on the normalization constant

In the textbook, Directional Statistics by Mardia and Jupp, the normalization constant given for the Von Mises Fisher probability density is apparently different from the one given here:

Cp(\kappa)

. In that book, the normalization constant is specified as:
*
C(\kappa)=
p
(\kappap/2-1
2)
\Gamma(p/2)Ip/2-1(\kappa)
where

\Gamma

is the gamma function. This is resolved by noting that Mardia and Jupp give the density "with respect to the uniform distribution", while the density here is specified in the usual way, with respect to Lebesgue measure. The density (w.r.t. Lebesgue measure) of the uniform distribution is the reciprocal of the surface area of the (p-1)-sphere, so that the uniform density function is given by the constant:

Cp(0)=

\Gamma(p/2)
2\pip/2
It then follows that:
*
C
p

(\kappa)=

Cp(\kappa)
Cp(0)
While the value for

Cp(0)

was derived above via the surface area, the same result may be obtained by setting

\kappa=0

in the above formula for

Cp(\kappa)

. This can be done by noting that the series expansion for

Ip/2-1(\kappa)

divided by

\kappap/2-1

has but one non-zero term at

\kappa=0

. (To evaluate that term, one needs to use the definition

00=1

.)

Support

The support of the Von Mises–Fisher distribution is the hypersphere, or more specifically, the

(p-1)

-sphere, denoted as

Sp-1=\left\{x\inRp:\left\|x\right\|=1\right\}

This is a

(p-1)

-dimensional manifold embedded in

p

-dimensional Euclidean space,

Rp

.

Relation to normal distribution

\kappa-1I

and mean

\boldsymbol{\mu}

of length

r>0

, whose density function is:

Gp(x;\boldsymbol{\mu},\kappa) =\left(\sqrt{

\kappa
2\pi
}\right)^p \exp\left(-\kappa \frac \right),the Von Mises–Fisher distribution is obtained by conditioning on

\left\|x\right\|=1

. By expanding

(x-\boldsymbol{\mu})'(x-\boldsymbol{\mu})=x'x+\boldsymbol{\mu}'\boldsymbol{\mu}-2\boldsymbol{\mu}'x,

and using the fact that the first two right-hand-side terms are fixed, the Von Mises-Fisher density,

fp(x;r-1\boldsymbol{\mu},r\kappa)

is recovered by recomputing the normalization constant by integrating

x

over the unit sphere. If

r=0

, we get the uniform distribution, with density

fp(x;\boldsymbol{0},0)

.

More succinctly, the restriction of any isotropic multivariate normal density to the unit hypersphere, gives a Von Mises-Fisher density, up to normalization.

This construction can be generalized by starting with a normal distribution with a general covariance matrix, in which case conditioning on

\left\|x\right\|=1

gives the Fisher-Bingham distribution.

Estimation of parameters

Mean direction

A series of N independent unit vectors

xi

are drawn from a von Mises–Fisher distribution. The maximum likelihood estimates of the mean direction

\mu

is simply the normalized arithmetic mean, a sufficient statistic:[3]

\mu=\bar{x}/\bar{R}, where \bar{x}=

1
N
N
\sum
i

xi, and \bar{R}=\|\bar{x}\|,

Concentration parameter

Use the modified Bessel function of the first kind to define

Ap(\kappa)=

Ip/2(\kappa)
Ip/2-1(\kappa)

.

Then:

\kappa=

-1
A
p

(\bar{R}).

Thus

\kappa

is the solution to

Ap(\kappa)=

\left\|
N
\sum
i
xi\right\|
N

=\bar{R}.

A simple approximation to

\kappa

is (Sra, 2011)

\hat{\kappa}=

\bar{R
(p-\bar{R}

2)}{1-\bar{R}2},

A more accurate inversion can be obtained by iterating the Newton method a few times

\hat{\kappa}1=\hat{\kappa}-

Ap(\hat{\kappa
)

-

2
\bar{R}}{1-A
p(\hat{\kappa})

-

p-1
\hat{\kappa
} A_p(\hat)},

\hat{\kappa}2=\hat{\kappa}1-

Ap(\hat{\kappa
1)-\bar{R}}{1-A

p(\hat{\kappa}

2-p-1
\hat{\kappa
1}

Ap(\hat{\kappa}1)}.

Standard error

For N ≥ 25, the estimated spherical standard error of the sample mean direction can be computed as:[4]

\hat{\sigma}=\left(

d
N\bar{R

2}\right)1/2

where

d=1-

1
N
N
\sum
i
2
\left(\mu
i\right)
It is then possible to approximate a

100(1-\alpha)\%

a spherical confidence interval (a confidence cone) about

\mu

with semi-vertical angle:

q=

1/2
\arcsin\left(e
\alpha

\hat{\sigma}\right),

where

e\alpha=-ln(\alpha).

For example, for a 95% confidence cone,

\alpha=0.05,e\alpha=-ln(0.05)=2.996,

and thus

q=\arcsin(1.731\hat{\sigma}).

Expected value

The expected value of the Von Mises–Fisher distribution is not on the unit hypersphere, but instead has a length of less than one. This length is given by

Ap(\kappa)

as defined above. For a Von Mises–Fisher distribution with mean direction

\boldsymbol{\mu}

and concentration

\kappa>0

, the expected value is:

Ap(\kappa)\boldsymbol{\mu}

. For

\kappa=0

, the expected value is at the origin. For finite

\kappa>0

, the length of the expected value is strictly between zero and one and is a monotonic rising function of

\kappa

.

The empirical mean (arithmetic average) of a collection of points on the unit hypersphere behaves in a similar manner, being close to the origin for widely spread data and close to the sphere for concentrated data. Indeed, for the Von Mises–Fisher distribution, the expected value of the maximum-likelihood estimate based on a collection of points is equal to the empirical mean of those points.

Entropy and KL divergence

The expected value can be used to compute differential entropy and KL divergence.

The differential entropy of

VMF(\boldsymbol{\mu},\kappa)

is:

l\langle-logfp(x;\boldsymbol{\mu},\kappa)r\ranglex\simVMF(\boldsymbol{\mu,\kappa)} =-logfp(Ap(\kappa)\boldsymbol{\mu};\boldsymbol{\mu},\kappa) =-logCp(\kappa)-\kappaAp(\kappa)

where the angle brackets denote expectation. Notice that the entropy is a function of

\kappa

only.

The KL divergence between

VMF(\boldsymbol{\mu0},\kappa0)

and

VMF(\boldsymbol{\mu1},\kappa1)

is:

l\langlelog

fp(x;\boldsymbol{\mu0
,

\kappa0)} {fp(x;\boldsymbol{\mu1},\kappa1)} r\rangle

x\simVMF(\boldsymbol{\mu0

,\kappa0)} =log

fp(Ap(\kappa0)\boldsymbol{\mu0
;

\boldsymbol{\mu0},\kappa0)} {fp(Ap(\kappa0)\boldsymbol{\mu0};\boldsymbol{\mu1},\kappa1)}

Transformation

Von Mises-Fisher (VMF) distributions are closed under orthogonal linear transforms. Let

U

be a

p

-by-

p

orthogonal matrix. Let

x\simVMF(\boldsymbol\mu,\kappa)

and apply the invertible linear transform:

y=Ux

. The inverse transform is

x=U'y

, because the inverse of an orthogonal matrix is its transpose:

U-1=U'

. The Jacobian of the transform is

U

, for which the absolute value of its determinant is 1, also because of the orthogonality. Using these facts and the form of the VMF density, it follows that:

y\simVMF(U\boldsymbol{\mu},\kappa).

One may verify that since

\boldsymbol{\mu}

and

x

are unit vectors, then by the orthogonality, so are

U\boldsymbol{\mu}

and

y

.

Pseudo-random number generation

General case

An algorithm for drawing pseudo-random samples from the Von Mises Fisher (VMF) distribution was given by Ulrich and later corrected by Wood.[5] An implementation in R is given by Hornik and Grün;[6] and a fast Python implementation is described by Pinzón and Jung.

To simulate from a VMF distribution on the

(p-1)

-dimensional unitsphere,

Sp-1

, with mean direction

\boldsymbol{\mu}\inSp-1

, these algorithms use the following radial-tangential decomposition for a point

x\inSp-1\subsetRp

:

x=t\boldsymbol{\mu}+\sqrt{1-t2}v

where

v\inRp

lives in the tangential

(p-2)

-dimensional unit-subsphere that is centered at and perpendicular to

\boldsymbol{\mu}

; while

t\in[-1,1]

. To draw a sample

x

from a VMF with parameters

\boldsymbol{\mu}

and

\kappa

,

v

must be drawn from the uniform distribution on the tangential subsphere; and the radial component,

t

, must be drawn independently from the distribution with density:
f
radial(t;\kappa,p)=(\kappa/2)\nu
\Gamma(
12)\Gamma(\nu+12)I
\nu(\kappa)

et\kappa(1-t2)

\nu-12

where
\nu=p
2-1
. The normalization constant for this density may be verified by using:

I\nu(\kappa)=

(\kappa/2)\nu
\Gamma(
12)\Gamma(\nu+12)
1
\int
-1

et\kappa(1-t2)

\nu-12

dt

as given in Appendix 1 (A.3) in Directional Statistics. Drawing the

t

samples from this density by using a rejection sampling algorithm is explained in the above references. To draw the uniform

v

samples perpendicular to

\boldsymbol{\mu}

, see the algorithm in, or otherwise a Householder transform can be used as explained in Algorithm 1 in.[7]

3-D sphere

To generate a Von Mises–Fisher distributed pseudo-random spherical 3-D unit vector[8] [9] \mathbf X_ on the S^sphere for a given \mu and \kappa, define

Xs=[r,\theta,\phi]

where \theta is the polar angle, \phi the azimuthal angle, and r=1 the distance to the center of the sphere

for \mathbf \mu = [0,(.),1] the pseudo-random triplet is then given by

Xs=[1,\arccosW,V]

where V is sampled from the continuous uniform distribution U(a,b) with lower bound a and upper bound b

V\simU(0,2\pi)

and

W=\cos\theta=1+

1
\kappa

(ln\xi+ln(1-

\xi-1
\xi

e-2\kappa))

where \xi is sampled from the standard continuous uniform distribution U(0,1)

\xi\simU(0,1)

here, Wshould be set to W = 1 when \mathbf \xi=0 and \mathbf X_ rotated to match any other desired \mu.

Distribution of polar angle

For

p=3

, the angle θ between

x

and

\boldsymbol{\mu}

satisfies

\cos\theta=\boldsymbol{\mu}Tx

. It has the distribution

p(\theta)=\intd2xf(x;\boldsymbol{\mu},\kappa)\delta\left(\theta-arccos(\boldsymbol{\mu}Tx)\right)

,which can be easily evaluated as

p(\theta)=2\piC3(\kappa)\sin\thetae\kappa\cos\theta

.

For the general case,

p\ge2

, the distribution for the cosine of this angle:

\cos\theta=t=\boldsymbol{\mu}Tx

is given by

fradial(t;\kappa,p)

, as explained above.

The uniform hypersphere distribution

When

\kappa=0

, the Von Mises–Fisher distribution,

VMF(\boldsymbol{\mu},\kappa)

on

Sp-1

simplifies to the uniform distribution on

Sp-1\subsetRp

. The density is constant with value

Cp(0)

. Pseudo-random samples can be generated by generating samples in

Rp

from the standard multivariate normal distribution, followed by normalization to unit norm.

Component marginal of uniform distribution

For

1\lei\lep

, let

xi

be any component of

x\inSp-1

. The marginal distribution for

xi

has the density:[10] [11]

fi(xi;p)=fradial(x

i;\kappa=0,p)=
2)
(1-x
p-1
2-1
i
Bl(
12,p-1
2r)

where

B(\alpha,\beta)

is the beta function. This distribution may be better understood by highlighting its relation to the beta distribution:
2&\simBetal(
12,p-1
2r)
&&and&
\begin{align} x
i
xi+1&\simBetal(
2
p-1
2,p-1
2r)

\end{align}

where the Legendre duplication formula is useful to understand the relationships between the normalization constants of the various densities above.

Note that the components of

x\inSp-1

are not independent, so that the uniform density is not the product of the marginal densities; and

x

cannot be assembled by independent sampling of the components.

Distribution of dot-products

In machine learning, especially in image classification, to-be-classified inputs (e.g. images) are often compared using cosine similarity, which is the dot product between intermediate representations in the form of unitvectors (termed embeddings). The dimensionality is typically high, with

p

at least several hundreds. The deep neural networks that extract embeddings for classification should learn to spread the classes as far apart as possible and ideally this should give classes that are uniformly distributed on

Sp-1

.[12] For a better statistical understanding of across-class cosine similarity, the distribution of dot-products between unitvectors independently sampled from the uniform distribution may be helpful.

Let

x,y\inSp-1

be unitvectors in

Rp

, independently sampled from the uniform distribution. Define:

\begin{align} t&=x'y\in[-1,1],& r&=

t+1
2

\in[0,1],& s&=logit(r)=log

1+t
1-t

\inR \end{align}

where

t

is the dot-product and

r,s

are transformed versions of it. Then the distribution for

t

is the same as the marginal component distribution given above;[11] the distribution for

r

is symmetric beta and the distribution for

s

is symmetric logistic-beta:

\begin{align} r&\simBetal(

p-1
2,p-1
2r),

& s&\sim

B
\sigmal(p-1
2,p-1
2r) \end{align}
The means and variances are:

\begin{align} E[t]&=0,&E[r]&=

12,
&

E[s]&=0, \end{align}

and
\begin{align} var[t]&=1p,var[r]&=
&
1{4p},
& var[s]&=2\psi'l(p-1
2r)4{p-1} \end{align}
where

\psi'=\psi(1)

is the first polygamma function. The variances decrease, the distributions of all three variables become more Gaussian, and the final approximation gets better as the dimensionality,

p

, is increased.

Generalizations

Matrix Von Mises-Fisher

The matrix von Mises-Fisher distribution (also known as matrix Langevin distribution[13] [14]) has the density

fn,(X;F)\propto\exp(\operatorname{tr}(FTX))

supported on the Stiefel manifold of

n x p

orthonormal p-frames

X

, where

F

is an arbitrary

n x p

real matrix.[15] [16]

Saw distributions

Ulrich,[17] in designing an algorithm for sampling from the VMF distribution, makes use of a family of distributions named after and explored by John G. Saw.[18] A Saw distribution is a distribution on the

(p-1)

-sphere,

Sp-1

, with modal vector

\boldsymbol{\mu}\inSp-1

and concentration

\kappa\ge0

, and of which the density function has the form:

fSaw(x;\boldsymbol\mu,\kappa) =

g(\kappax'\boldsymbol\mu)
Kp(\kappa)

where

g

is a non-negative, increasing function; and where

KP(\kappa)

is the normalization constant. The above-mentioned radial-tangential decomposition generalizes to the Saw family and the radial compoment,

t=x'\boldsymbol\mu

has the density:
f
Saw-radial(t;\kappa)=2\pip/2
\Gamma(p/2)
g(\kappat)(1-t2)(p-3)/2
Bl(
12,p-1
2r)K
p(\kappa)

.

where

B

is the beta function. Also notice that the left-hand factor of the radial density is the surface area of

Sp-1

.

By setting

g(\kappax'\boldsymbol\mu)=e\kappax'\boldsymbol\mu

, one recovers the VMF distribution.

Weighted Rademacher Distribution

The definition of the Von Mises-Fisher distribution can be extended to include also the case where

p=1

, so that the support is the 0-dimensional hypersphere, which when embedded into 1-dimensional Euclidean space is the discrete set,

\{-1,1\}

. The mean direction is

\mu\in\{-1,1\}

and the concentration is

\kappa\ge0

. The probability mass function, for

x\in\{-1,1\}

is:

f1(x\mid\mu,\kappa)=

e\kappa\mu
e-\kappa+e\kappa

=\sigma(2\kappa\mux)

where

\sigma(z)=1/(1+e-z)

is the logistic sigmoid. In the uniform case, at

\kappa=0

, this simplifies to the Rademacher distribution.

See also

References

  1. Fisher . R. A. . 10.1098/rspa.1953.0064 . Dispersion on a sphere . Proc. R. Soc. Lond. A . 217 . 295–305 . 1953. 1130 . 1953RSPSA.217..295F . 123166853 .
  2. Watson . G. S. . 10.2307/3213566 . Distributions on the Circle and on the Sphere . J. Appl. Probab. . 19 . 265–280 . 1980. 3213566 . 222325569 .
  3. Book: Directional Statistics . Mardia . Kanti . Kantilal Mardia . Jupp . P. E.. 1999 . John Wiley & Sons Ltd. . 978-0-471-95333-3.
  4. Book: Embleton, N. I. Fisher, T. Lewis, B. J. J.. Statistical analysis of spherical data. 1993. Cambridge University Press. Cambridge. 0-521-45699-1. 115–116. 1st pbk..
  5. Wood . Andrew T . Simulation of the Von Mises Fisher distribution . Communications in Statistics - Simulation and Computation . 1994 . 23 . 1 . 157–164 . 10.1080/03610919408813161 .
  6. Hornik . Kurt . Grün . Bettina . movMF: An R Package for Fitting Mixtures of Von Mises-Fisher Distributions . Journal of Statistical Software . 2014 . 58 . 10 . 10.18637/jss.v058.i10 . 13171102 . free .
  7. De Cao . Nicola . Aziz . Wilker . The Power Spherical distribution . 13 Feb 2023 . stat.ML . 2006.04437.
  8. Pakyuz-Charrier . Evren . Lindsay . Mark . Ogarko . Vitaliy . Giraud . Jeremie . Jessell . Mark . 2018-04-06 . Monte Carlo simulation for uncertainty estimation on structural data in implicit 3-D geological modeling, a guide for disturbance distribution selection and parameterization . Solid Earth . English . 9 . 2 . 385–402 . 10.5194/se-9-385-2018 . 2018SolE....9..385P . 1869-9510 . free .
  9. Book: A., Wood, Andrew T. . Simulation of the Von Mises Fisher distribution . 1992 . Centre for Mathematics & its Applications, Australian National University . 221030477.
  10. Gosmann . J . Eliasmith . C . Optimizing Semantic Pointer Representations for Symbol-Like Processing in Spiking Neural Networks . PLOS ONE . 2016 . 11 . 2 . e0149928 . 10.1371/journal.pone.0149928 . 26900931 . 4762696 . 2016PLoSO..1149928G . free .
  11. Web site: Voelker . Aaron R. . Gosmann . Jan . Stewart . Terrence C. . Efficiently sampling vectors and coordinates from the n-sphere and n-ball . Centre for Theoretical Neuroscience – Technical Report, 2017 . 22 April 2023.
  12. Wang . Tongzhou . Isola . Phillip . Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere . International Conference on Machine Learning (ICML) . 2020 . 2005.10242 .
  13. Pal . Subhadip . Sengupta . Subhajit . Mitra . Riten . Banerjee . Arunava . Conjugate Priors and Posterior Inference for the Matrix Langevin Distribution on the Stiefel Manifold . Bayesian Analysis . 2020 . 15 . 3 . 871–908 . 10.1214/19-BA1176 . 1936-0975. free .
  14. Chikuse . Yasuko . Concentrated matrix Langevin distributions . Journal of Multivariate Analysis . 1 May 2003 . 85 . 2 . 375–394 . 10.1016/S0047-259X(02)00065-9 . en . 0047-259X. free .
  15. Jupp . 1979 . Maximum likelihood estimators for the matrix von Mises-Fisher and Bingham distributions . The Annals of Statistics . 7 . 3 . 599–606 . 10.1214/aos/1176344681 . free .
  16. Downs . 1972 . Orientational statistics . Biometrika . 59 . 3 . 665–676 . 10.1093/biomet/59.3.665.
  17. Ulrich . Gary . Computer generation of distributions on the m-sphere . Applied Statistics . 1984 . 33 . 2 . 158–163 . 10.2307/2347441 . 2347441 .
  18. Saw . John G . A family of distributions on the m-sphere and some hypothesis tests . Biometrika . 1978 . 65 . ` . 69–73 . 10.2307/2335278 . 2335278 .

Further reading