skewness#
- pycafee.normalitycheck.gaussian.Gaussian.skewness(self, x_exp, alfa=None, details=None)#
This function applies the skewness 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
Skewness (\(S\)) is estimated using the following equation:
\[S=\frac{n}{(n-1)(n-2)}\sum_{i=1}^n\left(\frac{x_i - \overline{x}}{s}\right)^{3}\]The standard deviation of skewness (\(S_{std}\)) is estimated using the following equation:
\[S_{std} = \sqrt{\frac{6n(n-1)}{(n-2)(n+1)(n+3)}}\]and the test statistic (\(z_{S}\)) is estimated through the following equation:
\[z_{S} = \frac{S-0}{S_{std}}\]The test hypotheses are as follows:
☕
\(H_0:\) the skewness is Normal
\(H_1:\) the skewness 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 skewness is Normal else: the skewness 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.7.
- 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 = np.array([90, 72, 90, 64, 95, 89, 74, 88, 100, 77, 57, 35, 100, 64, 95, 65, 80, 84, 90, 100, 76]) >>> teste = Gaussian() >>> result, conclusion = teste.skewness(x, details='full') >>> print(result) SkewnessResult(Statistics=-2.0304772981338326, Critical=[-1.9599639845400545, 1.959963984540054], Alpha=0.05) >>> print(conclusion) Since the calculated statistic for the skewness (-2.03) is a value lower than the lower critical value (-1.959), we have evidence to reject the null hypothesis, and we can say that the distribution does not have skewness similar to the skewness of a Normal distribution (with 95.0% confidence).
>>> from pycafee.normalitycheck.gaussian import Gaussian >>> import numpy as np >>> x = np.array([5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9]) >>> teste = Gaussian(language='pt-br') >>> result, conclusion = teste.skewness(x) >>> print(result) ResultadoAssimetria(Estatistica=0.32955498519357374, Critico=[-1.9599639845400545, 1.959963984540054], Alfa=0.05) >>> print(conclusion) A Assimetria é Normal (95.0% de confiança)