rj_test#
- normtest.ryan_joiner.rj_test(x_data, alpha=0.05, cte_alpha='3/8', weighted=False)[source]#
This function applies the Ryan-Joiner Normality test [1].
- Parameters:
- x_datanumpy array
One dimension numpy array with at least
4observations.- alphafloat, optional
The level of significance (\(\alpha\)). Default is
0.05;- cte_alphastr, optional
A str with the cte_alpha value that should be adopted. The options are:
“0”;
“3/8” (default);
“1/2”;
- weightedbool, optional
Whether to estimate the Normal order considering the repeats as its average (True) or not (False, default). Only has an effect if the dataset contains repeated values;
- Returns:
- resulttuple with
- statisticfloat (positive)
The test statistic;
- critical
The critical value of the test;
- p_valuefloat or str
The probability of the test;
- conclusionstr
The test conclusion (e.g, Normal/Not Normal).
See also
Notes
The test statistic (\(R_{p}\)) is estimated through the correlation between the ordered data and the Normal statistical order:
\[R_{p}=\dfrac{\sum_{i=1}^{n}x_{(i)}z_{(i)}}{\sqrt{s^{2}(n-1)\sum_{i=1}^{n}z_{(i)}^2}}\]where \(z_{(i)}\) values are the z-score values of the corresponding experimental data (\(x_{({i)}}\)) value and \(s^{2}\) is the sample variance.
The correlation is estimated using
_statistic().The Normality test has the following assumptions:
☕
\(H_0:\) Data was sampled from a Normal distribution.
\(H_1:\) The data was sampled from a distribution other than the Normal distribution.
The conclusion of the test is based on the comparison between the critical value (at \(\alpha\) significance level) and statistic of the test:
☕
- if critical \(\leq\) statistic:
Fail to reject \(H_0:\) (e.g., data is Normal)
- else:
Reject \(H_0:\) (e.g., data is not Normal)
The critical values are obtained using
_critical_value().Warning
The estimated \(p_{value}\) may not be accurate as it is calculated using linear interpolation.
References
[1]RYAN, T. A., JOINER, B. L. Normal Probability Plots and Tests for Normality, Technical Report, Statistics Department, The Pennsylvania State University, 1976. Available at www.additive-net.de. Access on: 22 Jul. 2023.
Examples
>>> from normtest import ryan_joiner >>> from scipy import stats >>> data = stats.norm.rvs(loc=0, scale=1, size=30, random_state=42) >>> result = ryan_joiner.rj_test(data) >>> print(result) RyanJoiner(statistic=0.990439558451558, critical=0.963891667086667, p_value='p > 0.100', conclusion='Fail to reject H₀')