# Wrapped distribution

In probability theory and directional statistics, a wrapped probability distribution is a continuous probability distribution that describes data points that lie on a unit n-sphere. In one dimension, a wrapped distribution will consist of points on the unit circle. If φ is a random variate in the interval (-∞,∞) with probability density function p(φ), then z = e i φ will be a circular variable distributed according to the wrapped distribution pzw(z) and θ=arg(z) will be an angular variable in the interval (-π,π ] distributed according to the wrapped distribution pw(θ).

Any probability density function (pdf) ${\displaystyle p(\phi )}$ on the line can be "wrapped" around the circumference of a circle of unit radius.[1] That is, the pdf of the wrapped variable

${\displaystyle \theta =\phi \mod 2\pi }$ in some interval of length ${\displaystyle 2\pi }$

is

${\displaystyle p_{w}(\theta )=\sum _{k=-\infty }^{\infty }{p(\theta +2\pi k)}.}$

which is a periodic sum of period ${\displaystyle 2\pi }$. The preferred interval is generally ${\displaystyle (-\pi <\theta \leq \pi )}$ for which ${\displaystyle \ln(e^{i\theta })=\arg(e^{i\theta })=\theta }$

## Theory

In most situations, a process involving circular statistics produces angles (${\displaystyle \phi }$) which lie in the interval from negative infinity to positive infinity, and are described by an "unwrapped" probability density function ${\displaystyle p(\phi )}$. However, a measurement will yield a "measured" angle ${\displaystyle \theta }$ which lies in some interval of length ${\displaystyle 2\pi }$ (for example ${\displaystyle [0,2\pi )}$). In other words, a measurement cannot tell if the "true" angle ${\displaystyle \phi }$ has been measured or whether a "wrapped" angle ${\displaystyle \phi +2\pi a}$ has been measured where a is some unknown integer. That is:

${\displaystyle \theta =\phi +2\pi a.}$

If we wish to calculate the expected value of some function of the measured angle it will be:

${\displaystyle \langle f(\theta )\rangle =\int _{-\infty }^{\infty }p(\phi )f(\phi +2\pi a)d\phi .}$

We can express the integral as a sum of integrals over periods of ${\displaystyle 2\pi }$ (e.g. 0 to ${\displaystyle 2\pi }$):

${\displaystyle \langle f(\theta )\rangle =\sum _{k=-\infty }^{\infty }\int _{2\pi k}^{2\pi (k+1)}p(\phi )f(\phi +2\pi a)d\phi .}$

Changing the variable of integration to ${\displaystyle \theta '=\phi -2\pi k}$ and exchanging the order of integration and summation, we have

${\displaystyle \langle f(\theta )\rangle =\int _{0}^{2\pi }p_{w}(\theta ')f(\theta '+2\pi a')d\theta '}$

where ${\displaystyle p_{w}(\theta ')}$ is the pdf of the "wrapped" distribution and a' is another unknown integer (a'=a+k). It can be seen that the unknown integer a' introduces an ambiguity into the expectation value of ${\displaystyle f(\theta )}$. A particular instance of this problem is encountered when attempting to take the mean of a set of measured angles. If, instead of the measured angles, we introduce the parameter ${\displaystyle z=e^{i\theta }}$ it is seen that z has an unambiguous relationship to the "true" angle ${\displaystyle \phi }$ since:

${\displaystyle z=e^{i\theta }=e^{i\phi }.}$

Calculating the expectation value of a function of z will yield unambiguous answers:

${\displaystyle \langle f(z)\rangle =\int _{0}^{2\pi }p_{w}(\theta ')f(e^{i\theta '})d\theta '}$

and it is for this reason that the z parameter is the preferred statistical variable to use in circular statistical analysis rather than the measured angles ${\displaystyle \theta }$. This suggests, and it is shown below, that the wrapped distribution function may itself be expressed as a function of z so that:

${\displaystyle \langle f(z)\rangle =\oint p_{wz}(z)f(z)\,dz}$

where ${\displaystyle p_{w}(z)}$ is defined such that ${\displaystyle p_{w}(\theta )\,|d\theta |=p_{wz}(z)\,|dz|}$. This concept can be extended to the multivariate context by an extension of the simple sum to a number of ${\displaystyle F}$ sums that cover all dimensions in the feature space:

${\displaystyle p_{w}({\vec {\theta }})=\sum _{k_{1},...,k_{F}=-\infty }^{\infty }{p({\vec {\theta }}+2\pi k_{1}\mathbf {e} _{1}+\dots +2\pi k_{F}\mathbf {e} _{F})}}$

where ${\displaystyle \mathbf {e} _{k}=(0,\dots ,0,1,0,\dots ,0)^{\mathsf {T}}}$ is the ${\displaystyle k}$th Euclidean basis vector.

## Expression in terms of characteristic functions

A fundamental wrapped distribution is the Dirac comb which is a wrapped Dirac delta function:

${\displaystyle \Delta _{2\pi }(\theta )=\sum _{k=-\infty }^{\infty }{\delta (\theta +2\pi k)}.}$

Using the delta function, a general wrapped distribution can be written

${\displaystyle p_{w}(\theta )=\sum _{k=-\infty }^{\infty }\int _{-\infty }^{\infty }p(\theta ')\delta (\theta -\theta '+2\pi k)\,d\theta '.}$

Exchanging the order of summation and integration, any wrapped distribution can be written as the convolution of the "unwrapped" distribution and a Dirac comb:

${\displaystyle p_{w}(\theta )=\int _{-\infty }^{\infty }p(\theta ')\Delta _{2\pi }(\theta -\theta ')\,d\theta '.}$

The Dirac comb may also be expressed as a sum of exponentials, so we may write:

${\displaystyle p_{w}(\theta )={\frac {1}{2\pi }}\,\int _{-\infty }^{\infty }p(\theta ')\sum _{n=-\infty }^{\infty }e^{in(\theta -\theta ')}\,d\theta '}$

again exchanging the order of summation and integration,

${\displaystyle p_{w}(\theta )={\frac {1}{2\pi }}\,\sum _{n=-\infty }^{\infty }\int _{-\infty }^{\infty }p(\theta ')e^{in(\theta -\theta ')}\,d\theta '}$

using the definition of ${\displaystyle \phi (s)}$, the characteristic function of ${\displaystyle p(\theta )}$, yields a Laurent series about zero for the wrapped distribution in terms of the characteristic function of the unwrapped distribution:[2]

${\displaystyle p_{w}(\theta )={\frac {1}{2\pi }}\,\sum _{n=-\infty }^{\infty }\phi (n)\,e^{-in\theta }}$

or

${\displaystyle p_{wz}(z)={\frac {1}{2\pi }}\,\sum _{n=-\infty }^{\infty }\phi (n)\,z^{-n}.}$

By analogy with linear distributions, the ${\displaystyle \phi (m)}$ are referred to as the characteristic function of the wrapped distribution[2] (or perhaps more accurately, the characteristic sequence). This is an instance of the Poisson summation formula and it can be seen that the Fourier coefficients of the Fourier series for the wrapped distribution are just the Fourier coefficients of the Fourier transform of the unwrapped distribution at integer values.

## Moments

The moments of the wrapped distribution ${\displaystyle p_{w}(z)}$ are defined as:

${\displaystyle \langle z^{m}\rangle =\oint p_{wz}(z)z^{m}\,dz.}$

Expressing ${\displaystyle p_{w}(z)}$ in terms of the characteristic function and exchanging the order of integration and summation yields:

${\displaystyle \langle z^{m}\rangle ={\frac {1}{2\pi }}\sum _{n=-\infty }^{\infty }\phi (n)\oint z^{m-n}\,dz.}$

From the theory of residues we have

${\displaystyle \oint z^{m-n}\,dz=2\pi \delta _{m-n}}$

where ${\displaystyle \delta _{k}}$ is the Kronecker delta function. It follows that the moments are simply equal to the characteristic function of the unwrapped distribution for integer arguments:

${\displaystyle \langle z^{m}\rangle =\phi (m).}$

## Generation of random variates

If X is a random variate drawn from a linear probability distribution P, then ${\displaystyle Z=e^{iX}}$ will be a circular variate distributed according to the wrapped P distribution, and ${\displaystyle \theta =\arg(Z)}$ will be the angular variate distributed according to the wrapped P distribution, with ${\displaystyle -\pi <\theta \leq \pi }$.

## Entropy

The information entropy of a circular distribution with probability density ${\displaystyle p_{w}(\theta )}$ is defined as:[1]

${\displaystyle H=-\int _{\Gamma }p_{w}(\theta )\,\ln(p_{w}(\theta ))\,d\theta }$

where ${\displaystyle \Gamma }$ is any interval of length ${\displaystyle 2\pi }$. If both the probability density and its logarithm can be expressed as a Fourier series (or more generally, any integral transform on the circle) then the orthogonality property may be used to obtain a series representation for the entropy which may reduce to a closed form.

The moments of the distribution ${\displaystyle \phi (n)}$ are the Fourier coefficients for the Fourier series expansion of the probability density:

${\displaystyle p_{w}(\theta )={\frac {1}{2\pi }}\sum _{n=-\infty }^{\infty }\phi _{n}e^{-in\theta }}$

If the logarithm of the probability density can also be expressed as a Fourier series:

${\displaystyle \ln(p_{w}(\theta ))=\sum _{m=-\infty }^{\infty }c_{m}e^{im\theta }}$

where

${\displaystyle c_{m}={\frac {1}{2\pi }}\int _{\Gamma }\ln(p_{w}(\theta ))e^{-im\theta }\,d\theta }$

Then, exchanging the order of integration and summation, the entropy may be written as:

${\displaystyle H=-{\frac {1}{2\pi }}\sum _{m=-\infty }^{\infty }\sum _{n=-\infty }^{\infty }c_{m}\phi _{n}\int _{\Gamma }e^{i(m-n)\theta }\,d\theta }$

Using the orthogonality of the Fourier basis, the integral may be reduced to:

${\displaystyle H=-\sum _{n=-\infty }^{\infty }c_{n}\phi _{n}}$

For the particular case when the probability density is symmetric about the mean, ${\displaystyle c_{-m}=c_{m}}$ and the logarithm may be written:

${\displaystyle \ln(p_{w}(\theta ))=c_{0}+2\sum _{m=1}^{\infty }c_{m}\cos(m\theta )}$

and

${\displaystyle c_{m}={\frac {1}{2\pi }}\int _{\Gamma }\ln(p_{w}(\theta ))\cos(m\theta )\,d\theta }$

and, since normalization requires that ${\displaystyle \phi _{0}=1}$, the entropy may be written:

${\displaystyle H=-c_{0}-2\sum _{n=1}^{\infty }c_{n}\phi _{n}}$