ngp

mdtools.statistics.ngp(x, axis=None, d=1, center=False, is_squared=False)[source]

Compute the non-Gaussian parameter of a distribution of random variables.

Parameters:
  • x (array_like) – Input array.

  • axis (None or int or tuple of ints, optional) – Axis or axes of x along which to compute the NGP. By default, the flattened input array is used.

  • d (int, optional) – Dimensionality of the random variables (this is not the dimensionality of the input array). Originally, this option is provided to compute the NGP of a distribution of particle displacements \(\Delta\mathbf{r}\) that were calculated in one, two or three dimensional euclidean space.

  • center (bool, optional) – If True, center the input distribution around its mean, i.e. use central moments \(\langle (X - \bar{X})^n \rangle\) for computing the NGP (with \(\bar{X} = \sum_{i=1}^N X_i\) being the sample mean). If False, use the raw moments \(\langle X^n \rangle\) without subtracting the sample mean. Note that the central moments of the sample are biased estimators for the central moments of the population, whereas the raw moments of the sample are always equal to the raw moments of the population. See Wikipedia Moment (mathematics) § Sample moments center must not be used together with is_squared, because we cannot estimate the original sample mean if x is already squared.

  • is_squared (bool, optional) – If True, x is assumed to be already squared. If False (default), x will be squared before calculating the moments. Setting is_squared to True is for example useful if x is the distribution of squared particle displacements \(\Delta\mathbf{r}^2(\tau)\) of an ensemble of particles at a given lag time \(\tau\). is_squared must not be used together with center.

Returns:

a (scalar) – The non-Gaussian parameter \(\alpha_{2,d}\).

Notes

The non-Gaussian parameter (NGP) was first introduced by Rahman, Singwi, and Sjölander.[1],[2] Since then it has become a standard test to check for Gaussian diffusion, i.e. whether the particle displacements \(\Delta\mathbf{r}(\tau)\) follow a Gaussian distribution. For a Gaussian distribution the NGP is zero.

This function uses the definition of the NGP in \(d\)-dimensional euclidean space given in the text on page 12735 of Reference:[3]

\[\alpha_{2,d} = \frac{1}{1+\frac{2}{d}} \frac{\langle X^4 \rangle}{\langle X^2 \rangle^2} - 1\]

A more general definition of the NGP \(\alpha_{n,d}\) in \(d\)-dimensional euclidean space was given by Huang, Wang and Yu in Equation (14) of Reference:[4]

\[\alpha_{n,d} = \frac{(d-2)!! d^n}{(2n + d - 2)!!} \frac{\langle X^{2n} \rangle}{\langle X^2 \rangle^n} - 1\]

References

Examples

>>> mdt.stats.ngp(np.array([-2, -1, -1,  0,  0,  0,  1,  1,  2]))
-0.25
>>> a = mdt.stats.gaussian(np.linspace(-5, 5, 11))
>>> mdt.stats.ngp(a)
0.48352183005980653
>>> a = np.arange(24).reshape(2,3,4)
>>> mdt.stats.ngp(a)
-0.3876040703052728
>>> mdt.stats.ngp(a, center=True)
-0.401391304347826
>>> mdt.stats.ngp(a, axis=0)
array([[-0.33333333, -0.34113033, -0.35946667, -0.382643  ],
       [-0.4071511 , -0.43103845, -0.45333333, -0.47363871],
       [-0.49187475, -0.50812525, -0.52254957, -0.53533412]])
>>> mdt.stats.ngp(a, axis=0, center=True)
array([[-0.66666667, -0.66666667, -0.66666667, -0.66666667],
       [-0.66666667, -0.66666667, -0.66666667, -0.66666667],
       [-0.66666667, -0.66666667, -0.66666667, -0.66666667]])
>>> mdt.stats.ngp(a, axis=1)
array([[-0.32      , -0.37225959, -0.42285714, -0.46559096],
       [-0.6152    , -0.62068471, -0.62535515, -0.62936154]])
>>> mdt.stats.ngp(a, axis=1, center=True)
array([[-0.5, -0.5, -0.5, -0.5],
       [-0.5, -0.5, -0.5, -0.5]])
>>> mdt.stats.ngp(a, axis=2)
array([[-0.33333333, -0.61552028, -0.64866075],
       [-0.65763599, -0.66126512, -0.66307898]])
>>> mdt.stats.ngp(a, axis=2, center=True)
array([[-0.45333333, -0.45333333, -0.45333333],
       [-0.45333333, -0.45333333, -0.45333333]])