kurtosis#

pycafee.normalitycheck.gaussian.Gaussian.kurtosis(self, x_exp, alfa=None, details=None)#

This function applies the kurtosis test on a sample dataset using the method described by [1].

Parameters
x_expnumpy array

One dimension numpy array with at least 4 sample data.

alfafloat, optional

The level of significance (ɑ). Default is None which results in 0.05 (ɑ = 5%).

detailsstr, optional

The details parameter determines the amount of information presented about the hypothesis test.

  • If details = "short" (or None, e.g, the default), a simplified version of the test result is returned.

  • If details = "full", a detailed version of the hypothesis test result is returned.

  • if details = "binary", the conclusion will be 1 (\(H_0\) is rejected) or 0 (\(H_0\) is accepted).

Returns
resulttuple with
statisticfloat

The test statistic.

criticallist of two floats

The critical values for the adopted significance level, where:

  • critical[0] is the lower critical value (always negative);

  • critical[1] is the upper critical value (always positive);

alphafloat

The adopted level of significance.

conclusionstr or int

The test conclusion (e.g, Normal/ not Normal).

Notes

Kurtosis (\(K\)) is estimated using the following equation:

\[K=\frac{n\left(n+1\right)}{(n-1)(n-2)(n-3)}\sum_{i=1}^n\left(\frac{x_i - \overline{x}}{s}\right)^{4}-\frac{3(n-1)^2}{(n-2)(n-3)}\]

The standard deviation of kurtosis (\(K_{std}\)) is estimated using the following equation:

\[K_{std}=\sqrt{\frac{24n(n-1)^2}{(n-2)(n-3)(n+5)(n+3)}}\]

and the test statistic (\(z_{K}\)) is estimated through the following equation:

\[z_{K} = \frac{K-0}{K_{std}}\]

The test hypotheses are as follows:

\(H_0:\) the kurtosis is Normal

\(H_1:\) the kurtosis is Not Normal

The comparison is performed between the calculated test statistic and the critical values (at alpha significance level) as follows:

if critical.Lower <= statistic <= critical.Upper:
    the kurtosis is Normal
else:
    the kurtosis is Not Normal

The lower critical value is obtained with alfa/2 and the upper critical value is obtained with 1 - alfa/2 significance level (e.g., two side distribution), using stats.norm.ppf() [2].

References

1

CORDER, G. W.; FOREMAN, D. I. NONPARAMETRIC STATISTICS A Step-by-Step Approach. 2. ed. New Jersey: John Wiley & Sons, 2014, p. 19, eq 2.5.

2

SCIPY. stats.norm.ppf. Available at: https://docs.scipy.org. Access on: 10 May. 2022.

Examples

>>> from pycafee.normalitycheck.gaussian import Gaussian
>>> import numpy as np
>>> x_exp = np.array([1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9])
>>> test = Gaussian()
>>> result, conclusion = test.kurtosis(x_exp, details='full')
>>> print(result)
KurtosisResult(Statistics=2.802450152883085, Critical=[-1.9599639845400545, 1.959963984540054], Alpha=0.05)
>>> print(conclusion)
Since the calculated statistic for the kurtosis (2.802) is a value higher than the upper critical value (1.959), we have evidence to reject the null hypothesis, and we can say that the distribution does not have kurtosis similar to the kurtosis of a Normal distribution (with 95.0% confidence).
>>> from pycafee.normalitycheck.gaussian import Gaussian
>>> import numpy as np
>>> x_exp = np.array([90, 72, 90, 64, 95, 89, 74, 88, 100, 77, 57, 35, 100, 64, 95, 65, 80, 84, 90, 100, 76])
>>> test = Gaussian(language='pt-br')
>>> result, conclusion = test.kurtosis(x_exp)
>>> print(result)
ResultadoCurtose(Estatistica=1.186374537979677, Critico=[-1.9599639845400545, 1.959963984540054], Alfa=0.05)
>>> print(conclusion)
A Curtose é Normal (95.0% de confiança)