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_exp
numpy array One dimension numpy array with at least 4 sample data.
- alfa
float, optional The level of significance (
ɑ). Default isNonewhich results in0.05(ɑ = 5%).- details
str, optional The
detailsparameter determines the amount of information presented about the hypothesis test.If
details = "short"(orNone, 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 be1(\(H_0\) is rejected) or0(\(H_0\) is accepted).
- x_exp
- Returns
- result
tuplewith - statistic
float The test statistic.
- critical
listof twofloats 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);
- alpha
float The adopted level of significance.
- statistic
- conclusion
strorint The test conclusion (e.g, Normal/ not Normal).
- result
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
statisticand thecriticalvalues (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/2and the upper critical value is obtained with1 - alfa/2significance 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)