Skip to content

Home / Statistical Tools / Analysis Tools / Summarystats / Math Details

Math Details

This page gives the exact formulas Quantum XL uses to compute descriptive statistics. Each equation lists what it computes and where it appears in the output. (Elementary outputs such as count, sum, minimum, maximum, range, and mode are omitted.)

Notation

Term Description
\(x_{(1)} \le \dots \le x_{(n)}\) the data values sorted ascending
\(x_i, w_i\) value and its frequency weight (\(w_i = 1\) when no frequency column is used)
\(n\) effective sample size, \(n = \sum_i w_i\)
\(\bar{x}\) weighted mean, \(\bar{x} = \dfrac{\sum_i w_i x_i}{\sum_i w_i}\)
\(M_k\) weighted central moment sum, \(M_k = \sum_i w_i (x_i - \bar{x})^k\)
\(\Phi\) standard normal cumulative distribution function

Variance and standard deviation

\[ s^2_{\text{sample}} = \frac{M_2}{n - 1}, \qquad s^2_{\text{population}} = \frac{M_2}{n}, \qquad s = \sqrt{s^2} \]

The sample forms use the \(n-1\) (Bessel) denominator; both population and sample versions are reported.

Skewness (Fisher-Pearson standardized, \(G_1\))

\[ G_1 = \frac{n\sqrt{n - 1}}{n - 2}\cdot\frac{M_3}{M_2^{\,3/2}} \]

Requires \(n > 2\); undefined for constant data. This is the bias-adjusted (\(G_1\)) form used by most statistical packages.

Kurtosis (excess, \(G_2\))

\[ G_2 = \frac{(n + 1)\,n\,(n - 1)}{(n - 2)(n - 3)}\cdot\frac{M_4}{M_2^{\,2}} \;-\; \frac{3\,(n - 1)^2}{(n - 2)(n - 3)} \]

Excess kurtosis (a normal distribution gives \(0\)). Requires \(n > 3\).

Quantiles, quartiles, and percentiles

All percentiles, including the median and quartiles, use the Hyndman-Fan Type 8 estimator, which interpolates between the two order statistics nearest a fractional rank and is approximately median-unbiased. The median is \(Q(0.5)\), the first quartile is \(Q_1 = Q(0.25)\), and the third quartile is \(Q_3 = Q(0.75)\); Summary Statistics also reports the 1, 5, 10, 90, 95, and 99 percentiles and any custom percentiles. For a probability \(p\), the quantile \(Q(p)\) is:

\[ h = \left(n + \tfrac{1}{3}\right)p + \tfrac{1}{3} \]
\[ Q(p) = x_{(\lfloor h \rfloor)} + \left(h - \lfloor h \rfloor\right)\left(x_{(\lfloor h \rfloor + 1)} - x_{(\lfloor h \rfloor)}\right) \]

where \(x_{(1)} \le \cdots \le x_{(n)}\) are the \(n\) data values sorted ascending and \(\lfloor h \rfloor\) is the greatest integer not exceeding \(h\). The two indices are clamped to the range \([1, n]\) and the interpolation weight \(h - \lfloor h \rfloor\) is clamped to \([0, 1]\), so the ends behave as \(Q(0) = x_{(1)}\) (the minimum) and \(Q(1) = x_{(n)}\) (the maximum).

When each value carries a frequency \(f_i\), Quantum XL applies the same estimator to the virtual sample formed by repeating each value \(f_i\) times, without physically expanding it. The total count is \(N = \sum_i f_i\), and the position becomes:

\[ h = \left(N + \tfrac{1}{3}\right)p + \tfrac{1}{3} \]

Let \(V(t)\) be the value at position \(t\) of the sorted virtual sample, that is the smallest value whose cumulative frequency reaches \(t\). The quantile is:

\[ Q(p) = V(\lfloor h \rfloor) + \left(h - \lfloor h \rfloor\right)\left(V(\lfloor h \rfloor + 1) - V(\lfloor h \rfloor)\right) \]

with the same end clamping. This gives exactly the result of expanding the data and applying the unweighted formula.

Full details: Type 8 (Hyndman-Fan) Quantiles.

Confidence intervals

Summary Statistics reports a confidence interval for the mean, using the Student t distribution, and a confidence interval for the standard deviation, using the chi-square distribution. Both use \(\alpha = 1 - \text{(confidence level)}\) and the sample standard deviation \(s\) with the \(n - 1\) denominator.

Mean (Student t):

\[ \bar{x} \pm t_{\,df,\,1-\alpha/2}\,\frac{s}{\sqrt{n}}, \qquad df = n - 1 \]

where \(t_{\,df,\,1-\alpha/2}\) is the \((1 - \alpha/2)\) quantile of the Student t distribution.

Standard deviation (chi-square):

\[ \left[\ \sqrt{\frac{(n-1)\,s^2}{\chi^2_{\,n-1,\,1-\alpha/2}}}\ ,\ \ \sqrt{\frac{(n-1)\,s^2}{\chi^2_{\,n-1,\,\alpha/2}}}\ \right] \]

with \(df = n - 1\), where \(\chi^2_{\,df,\,q}\) is the \(q\)-quantile of the chi-square distribution. Constant data (\(s^2 = 0\)) returns a zero-width interval.

Full details: Student t Distribution and Chi-Square Distribution.

Normality tests

Anderson-Darling

Quantum XL reports the Anderson-Darling statistic and its p-value as the primary normality check. The statistic compares the sorted, standardized data against the normal CDF; Quantum XL evaluates a frequency-weighted form, applies Stephens' finite-sample correction, and obtains the p-value from Stephens' approximation.

\[ A^2 = -n - \frac{1}{n}\sum_{i=1}^{n}(2i - 1)\left[\ln F\!\left(x_{(i)}\right) + \ln\!\left(1 - F\!\left(x_{(n+1-i)}\right)\right)\right] \]

\(F\) is the standard normal CDF applied to the standardized value, \(F(x) = \Phi\!\left((x - \bar{x})/s\right)\), and \(x_{(1)} \le \cdots \le x_{(n)}\) are the \(n\) values being tested, sorted ascending. When Quantum XL tests a sample for normality, \(\bar{x}\) and \(s\) are the sample mean and sample standard deviation (\(n - 1\) denominator). When it tests a fitted distribution (for example in distribution fitting), \(F\) uses the fitted parameters instead of re-estimating them.

The statistic is adjusted for sample size using the Stephens correction:

\[ A^{*2} = A^2\left(1 + \frac{0.75}{n} + \frac{2.25}{n^2}\right) \]

The p-value is a piecewise function of the adjusted statistic:

\[ p = \begin{cases} 0 & A^{*2} > 13 \\[4pt] \exp\!\left(1.2937 - 5.709\,A^{*2} + 0.0186\,(A^{*2})^2\right) & 0.6 \le A^{*2} \le 13 \\[4pt] \exp\!\left(0.9177 - 4.279\,A^{*2} - 1.38\,(A^{*2})^2\right) & 0.34 \le A^{*2} < 0.6 \\[4pt] 1 - \exp\!\left(-8.318 + 42.796\,A^{*2} - 59.938\,(A^{*2})^2\right) & 0.2 \le A^{*2} < 0.34 \\[4pt] 1 - \exp\!\left(-13.436 + 101.14\,A^{*2} - 223.73\,(A^{*2})^2\right) & A^{*2} < 0.2 \end{cases} \]

The reported p-value is clamped to a minimum of \(0.005\).

Full details: Anderson-Darling Test.

Shapiro-Wilk

\[ W = \frac{\left(\sum_{i=1}^{n} a_i\, x_{(i)}\right)^2}{\sum_{i=1}^{n} (x_i - \bar{x})^2} \]

\(x_{(1)} \le \cdots \le x_{(n)}\) are the values sorted ascending and \(\bar{x}\) is their mean. The constants \(a_i\) are derived from the expected values and covariances of standard normal order statistics; Quantum XL computes them with Royston's Algorithm AS R94. \(W\) is close to \(1\) when the data follow a normal distribution.

The p-value comes from Royston's normalizing transformation. For \(n = 3\) the exact value \(p = \frac{6}{\pi}\left(\arcsin\sqrt{W} - \frac{\pi}{3}\right)\) is used. For \(4 \le n \le 11\) the statistic is transformed with \(y = -\ln\!\big(\gamma - \ln(1 - W)\big)\), and for \(n > 11\) with \(y = \ln(1 - W)\); in both cases \(y\) is standardized with sample-size-dependent mean and standard deviation polynomials, and the p-value is the upper tail of the standard normal distribution for the resulting \(z\).

For Summary Statistics, frequency weights are respected by virtually expanding each value to its frequency count. Full details: Shapiro-Wilk Test.

Kolmogorov-Smirnov (with Lilliefors correction)

\[ D^{+} = \max_i\left(F_n(x_{(i)}) - \Phi(z_{(i)})\right), \qquad D^{-} = \max_i\left(\Phi(z_{(i)}) - F_n(x_{(i-1)})\right), \qquad D = \max(D^{+}, D^{-}) \]

\(F_n\) is the empirical cumulative distribution function of the sorted data, and \(z_{(i)} = (x_{(i)} - \bar{x})/s\) standardizes each value with the sample mean and sample standard deviation. \(D\) is the largest vertical distance between the empirical CDF and the fitted normal CDF.

Because the mean and standard deviation are estimated from the same sample, the classical Kolmogorov-Smirnov distribution does not apply. Quantum XL forms a sample-size modified statistic:

\[ D^{*} = D\left(\sqrt{n} - 0.01 + \frac{0.85}{\sqrt{n}}\right) \]

and reads the p-value from tabulated critical values for the case where the mean and variance are estimated from the sample, interpolating linearly within each bracket:

Modified statistic Reported p-value
\(D^{*} < 0.775\) \(0.15\), printed with a greater-than prefix
\(0.775 \le D^{*} < 0.819\) \(0.10 + 0.05\left(1 - \dfrac{D^{*} - 0.775}{0.044}\right)\)
\(0.819 \le D^{*} < 0.895\) \(0.05 + 0.05\left(1 - \dfrac{D^{*} - 0.819}{0.076}\right)\)
\(0.895 \le D^{*} < 0.995\) \(0.025 + 0.025\left(1 - \dfrac{D^{*} - 0.895}{0.100}\right)\)
\(0.995 \le D^{*} < 1.035\) \(0.01 + 0.015\left(1 - \dfrac{D^{*} - 0.995}{0.040}\right)\)
\(D^{*} \ge 1.035\) \(0.01\), printed with a less-than prefix

So the reportable p-value range is exactly \(0.01\) to \(0.15\). Outside the table the value is pinned to the nearer endpoint and printed with a prefix, for example > 0.15 for a sample that agrees closely with the normal model.

Kolmogorov-Smirnov also requires variation in the data: when the standard deviation is zero, no statistic and no p-value are reported.

For Summary Statistics, \(F_n\) is the cumulative-frequency CDF, so frequency weights are respected. Full details: Kolmogorov-Smirnov Test.

Shared Math Details used here

This tool uses shared formulas defined once in Shared Math Details. See those pages for the exact definitions.

Shared concept Used here for Reference
Anderson-Darling test the normality test statistic and p-value Anderson-Darling Test
Shapiro-Wilk test the second normality test Shapiro-Wilk Test
Kolmogorov-Smirnov test the third normality test Kolmogorov-Smirnov Test
Type 8 quantiles the median, quartiles, and percentiles Type 8 (Hyndman-Fan) Quantiles
Student t distribution the confidence interval for the mean Student t Distribution
Chi-square distribution the confidence interval for the standard deviation Chi-Square Distribution
Standard normal distribution the normality tests Standard Normal Distribution

See Also

References

  • Snedecor, G. W., & Cochran, W. G. (1989). Statistical Methods (8th ed.). Ames, IA: Iowa State University Press.
  • Joanes, D. N., & Gill, C. A. (1998). Comparing measures of sample skewness and kurtosis. Journal of the Royal Statistical Society: Series D (The Statistician), 47(1), 183-189.
  • Hyndman, R. J., & Fan, Y. (1996). Sample quantiles in statistical packages. The American Statistician, 50(4), 361-365.
  • Anderson, T. W., & Darling, D. A. (1952). Asymptotic theory of certain goodness-of-fit criteria based on stochastic processes. Annals of Mathematical Statistics, 23(2), 193-212.
  • Stephens, M. A. (1974). EDF statistics for goodness of fit and some comparisons. Journal of the American Statistical Association, 69(347), 730-737.
  • D'Agostino, R. B., & Stephens, M. A. (Eds.). (1986). Goodness-of-Fit Techniques. New York: Marcel Dekker.
  • Shapiro, S. S., & Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3/4), 591-611.
  • Royston, P. (1995). Remark AS R94: A remark on Algorithm AS 181: The W test for normality. Journal of the Royal Statistical Society: Series C (Applied Statistics), 44(4), 547-551.
  • Lilliefors, H. W. (1967). On the Kolmogorov-Smirnov test for normality with mean and variance unknown. Journal of the American Statistical Association, 62(318), 399-402.
  • Massey, F. J. (1951). The Kolmogorov-Smirnov test for goodness of fit. Journal of the American Statistical Association, 46(253), 68-78.