Algorithm Lab
Verified statistical algorithms with formulas, assumptions and references. Every algorithm is validated against Minitab, R, or NIST reference data.
Distributions & Tests
Math Utility Functions (Distributions)
Collection of numerical distribution functions (normal, χ², t, F) — the foundation of all hypothesis tests.
Random Variates from Statistical Distributions
Generation of pseudo-random numbers from over 20 continuous and discrete distributions using the Mulberry32 PRNG.
Process Capability
Process Capability Cp
Measures process spread relative to the tolerance width, ignoring centering.
Process Capability Index Cpk
Measures how well a process fits within specification limits, accounting for centering.
Overall Process Capability Ppk
Overall process capability based on total variation (population σ, ddof = 0).
Hypothesis Tests
Shapiro-Wilk Test
Tests whether a sample comes from a normally distributed population.
Anderson-Darling Test
Tests whether a sample comes from a normally distributed population — especially sensitive in the distribution tails.
Jarque-Bera Test
Asymptotic normality test based on skewness and kurtosis (chi-squared with 2 degrees of freedom). Reliable for large samples (n > 30).
D'Agostino-Pearson Omnibus Test
Omnibus normality test: Combines Z-scores from skewness and kurtosis into a χ²(2) test statistic. Requires n ≥ 20.
Chi-Square Variance Test
Tests whether the population variance equals a hypothesized value (one-sample variance test).
F-Test (Variance Equality)
Tests whether two normally distributed populations have equal variances.
Levene Test (Brown-Forsythe)
Robust test for equality of variances of two samples, insensitive to non-normality.
One-Sample t-Test
Tests whether the population mean equals a hypothesized value.
Two-Sample t-Test (pooled)
Compares the means of two independent samples assuming equal variances.
Welch t-Test
Compares the means of two independent samples without assuming equal variances.
Wilcoxon Signed-Rank Test
Nonparametric alternative to the one-sample t-test for the median.
Mann-Whitney U Test
Nonparametric alternative to the two-sample t-test for independent samples.
One-Way ANOVA
Compares the means of k independent, normally distributed samples.
Kruskal-Wallis Test
Nonparametric alternative to one-way ANOVA for k samples.
Bartlett's Test
Parametric test for equality of variances of k ≥ 2 normally distributed samples.
Outlier Tests
Grubbs' Test
Identifies a single outlier in normally-distributed data.
Dixon Q Test
Outlier test for very small samples (n = 3..30) based on range ratios.
Generalized ESD (Rosner 1983)
Iterative test that identifies up to k outliers simultaneously, avoiding masking.
Tukey IQR Rule
Distribution-free outlier flagging via boxplot whisker fences.
Hampel Identifier
Robust Z-score replacement using median and MAD — resistant to masking.
Z-Score (Outliers)
Flags points with |Z| > threshold using mean and standard deviation.
Modified Z-Score
Robust Z-score variant by Iglewicz & Hoaglin (1993) — based on median and MAD.
Regression & Correlation
Regression ANOVA (Variance Decomposition)
Decomposes total variation of the response into explained (regression) and unexplained (residual) components.
Regression Coefficients (t-Test & Confidence Intervals)
Tests the significance of individual regression coefficients via t-test and determines confidence intervals.
Correlation Analysis (Pearson, Spearman, Kendall)
Computes Pearson r, Spearman ρ and Kendall τ including p-values and confidence intervals.
Logistic Regression (Binomial GLM)
Models a binary response (0/1) as a function of predictors using the logistic link function and IRLS estimation.
Poisson Regression
Generalized linear model for count data with log link function and Poisson distribution.
Negative Binomial Regression
Regression model for overdispersed count data using a log link and negative binomial distribution.
ROC Curve & AUC
Computes the ROC curve (Receiver Operating Characteristic) and the Area Under the Curve (AUC) for binary classification.
Hosmer-Lemeshow Test
Tests the goodness of fit of a logistic regression model using groups of predicted probabilities.
Overdispersion Check
Checks for overdispersion in count data models using the Pearson χ²/df ratio.
Lack-of-Fit Test (F-Test from Replicate Observations)
Compares model mis-specification against pure noise from replicated design points.
Effect Coding (Sum-to-Zero) for Categorical Factors
Maps a categorical factor with k levels onto k − 1 indicator columns; the intercept becomes the grand mean.
Block-Significance F-Test (Type-III SS for a Factor Block)
Wald-form F-test for a group of related model-matrix columns — typically the n − 1 indicators that encode one categorical factor.
Measurement System Analysis
Repeatability Index Cg (MSA Type 1)
Evaluates the repeatability of a measurement instrument: How large is the spread of repeated measurements relative to the tolerance?
Repeatability and Bias Index Cgk (MSA Type 1)
Evaluates repeatability and systematic deviation (bias) of a measurement instrument in a single index.
Gage R&R — ANOVA-Based Measurement System Analysis Type 2
Decomposes measurement variation into repeatability (EV), reproducibility (AV), and part-to-part variation using two-factor crossed ANOVA with interaction.
Control Charts
SPC Control Charts (I-MR, X̄-R, X̄-S)
Control chart core values (CL, UCL, LCL, σ̂) for I-MR, X̄-R and X̄-S plus Nelson Rule evaluation and capability from σ̂.
Attribute Control Charts (p, np, c, u)
Control chart core values (CL, UCL, LCL, σ̂) for p, np, c, u charts plus reduced Nelson rule evaluation.
Run Chart (runs tests)
Median plus four runs tests (clustering, mixtures, trends, oscillation) with p-values from a normal approximation.
Time-Weighted Control Charts (EWMA, CUSUM)
EWMA and tabular CUSUM with transient/fixed control limits for small drifts.
Rare-Event Control Charts (g, t)
g chart (Benneyan) and t chart (Nelson 1/3.6 transform) for rare events.
Multivariate Control Chart (Hotelling T²)
Hotelling T² for individual observations with Phase II UCL from the F distribution.
Z-MR (Short-Run Control Chart)
Standardised I-MR across multiple parts with different targets/spreads.
Box-Cox-Transformed I-MR Control Chart
Box-Cox transform with auto λ via Anderson-Darling, I-MR on the transformed scale, back-transformed limits.
Design of Experiments
Design Efficiency (D, A, G)
Evaluates the quality of an experimental design using three criteria: D-efficiency (determinant), A-efficiency (trace), and G-efficiency (leverage).
DoE Planner (Design Generation)
Generates structural experimental designs: full 2^k, fractional 2^(k-p), CCD and Box-Behnken.
Variance Inflation Factors (VIF)
Measures multicollinearity between model terms in an experimental design.
Full Factorial Design with Mixed Level Counts
Generates the Cartesian product of all level combinations when factors have different level counts (e.g. 2 × 3 × 4).
Taguchi L18 (2¹·3⁷, Mixed-Level Array)
Orthogonal array with 18 runs and one 2-level plus seven 3-level columns — the classic mixed-level screening design.
CCD with Categorical Factors (Cartesian × Continuous CCD)
Extends the classical central composite design to plans with mixed continuous/categorical factors — every categorical level combination gets a full CCD over the continuous factors.
Box-Behnken with Categorical Factors (Cartesian × Continuous BB)
Extends the Box-Behnken design to mixed factors — continuous get the classical 3-level RSM plan, categorical are Cartesian-crossed alongside.
D-Optimal Design with Mixed Level Counts
D-optimal search that constrains categorical factors to their discrete levels — continuous factors keep the 5-level grid for quadratic models.
Response Optimization
Desirability Function (Derringer-Suich)
Maps a response value y onto a dimensionless desirability d ∈ [0, 1] — the building block of multi-response optimisation.
Composite Desirability D (Geometric Mean)
Blends several individual desirabilities d_i into a single composite D ∈ [0, 1] via the weighted geometric mean.
Pareto Frontier (2D, Non-Dominance Filter)
Filters a set of points down to the non-dominated solutions — the Pareto frontier of a multi-objective optimisation.
Hybrid Search (Grid over Categorical × Nelder–Mead over Continuous)
Optimises models with mixed factors: enumerates the Cartesian product of categorical level combinations and runs a continuous multi-start Nelder–Mead inside each cell.