Classical non-iterative Grubbs test for a single outlier
[outlierfree, outlier] = ST_grubbs(v, p) [outlierfree, outlier] = ST_grubbs(v, p, side) outlierfree = ST_grubbs(v, p) outlierfree = ST_grubbs(v, p, side)
real vector of numerical sample values; at least three values are required
statistical confidence level as a string or significance level α as a decimal value "95%", "99%", "99.9%", 0.05, 0.01 or 0.001
test direction, "both" (default), "left" or "right"
input vector with the detected outlier removed; unchanged if the test does not identify an outlier
detected outlier as a scalar vector; [] if no outlier is detected
ST_grubbs performs the classical, non-iterative Grubbs test and can detect at most one outlier in a sample. The test is performed exactly once on the complete input vector. It is therefore not affected by the changing critical limits and accumulated type-I error associated with repeated application.
The test assumes that the observations are independent and approximately normally distributed. A minimum sample size of n >= 3 is required. The test has limited power for very small samples, and a non-significant result must not be interpreted as proof that the sample contains no outlier.
Test directions:
"both" tests the observation with the largest absolute deviation from the sample mean. The critical probability uses α/(2*n).
"left" tests only the minimum observation. The critical probability uses α/n.
"right" tests only the maximum observation. The critical probability uses α/n.
The sample standard deviation is calculated with denominator n-1. If all sample values are identical, the standard deviation is zero and no outlier is returned.
Test statistic

Critical value

Decision rule
The selected observation is classified as an outlier when G > Gcrit. Equality does not lead to rejection.
Grubbs, F. E. (1950). Sample criteria for testing outlying observations. Annals of Mathematical Statistics, 21(1), 27-58.
Grubbs, F. E. (1969). Procedures for detecting outlying observations in samples. Technometrics, 11(1), 1-21.
NIST/SEMATECH e-Handbook of Statistical Methods, Grubbs' Test for Outliers.