Detect anomalies, set control limits, and monitor process stability using statistical methods.
Kotlin Notebook
Try this guide as a Kotlin Notebook with Kandy visualizations — run the cells to see charts and explore the data interactively.
This guide uses temperature sensor readings from a manufacturing line to demonstrate anomaly detection, control limit computation, and process stability testing.
val summary = sensorReadings.describe()summary.meansummary.standardDeviationsummary.min // check for unusually low valuessummary.max // check for unusually high valuessummary.interquartileRange
Verify that readings follow the expected distribution.
Copy
// Exclude known outliers for fittingval cleanReadings = sensorReadings.filter { it in 150.0..160.0 }.toDoubleArray()val fitted = NormalDistribution( mu = cleanReadings.mean(), sigma = cleanReadings.standardDeviation())val ks = kolmogorovSmirnovTest(cleanReadings, fitted)ks.pValue // high p-value supports the normal process model
After fitting a process distribution, use quantile() to set thresholds:
fitted.quantile(0.001) and fitted.quantile(0.999) give 99.8% coverage bounds.