The Kolmogorov-Smirnov (KS) test is a nonparametric goodness-of-fit test that determines whether two independent samples are drawn from the same continuous distribution. It calculates the KS statistic, defined as the maximum absolute difference between the empirical cumulative distribution functions (ECDFs) of the two samples. In model monitoring, it compares the distribution of a feature in the training data against its distribution in live inference data, providing a scalar metric to flag data drift.
Glossary
Kolmogorov-Smirnov Test (KS Test)

What is Kolmogorov-Smirnov Test (KS Test)?
The Kolmogorov-Smirnov test is a nonparametric statistical method used to quantify the divergence between two probability distributions, commonly applied in MLOps to detect feature drift in production machine learning models.
The test outputs a p-value indicating the statistical significance of the observed divergence; a low p-value (typically < 0.05) rejects the null hypothesis that the distributions are identical. Unlike the Population Stability Index (PSI), the KS test does not require binning continuous variables, making it sensitive to shifts in the tails of a distribution. It is frequently paired with Kullback-Leibler Divergence and Wasserstein Distance as part of a comprehensive continuous evaluation framework to trigger triggered retraining pipelines.
Key Properties of the KS Test
The Kolmogorov-Smirnov test is a nonparametric method for quantifying the distance between two empirical distributions. It is a foundational tool in MLOps for detecting feature drift and covariate shift.
Nonparametric Nature
The KS test makes no assumptions about the underlying data distribution. It does not require the data to follow a Gaussian curve, making it robust for financial transaction features that often exhibit heavy-tailed or multimodal distributions.
- Distribution-Free: Works directly on the empirical cumulative distribution function (ECDF).
- Versatile: Applicable to continuous variables like transaction amounts or risk scores.
- Limitation: Sensitivity is highest near the center of the distribution and lower at the tails.
The D-Statistic
The test statistic, D, is the maximum absolute vertical distance between the two empirical cumulative distribution functions (ECDFs).
- Calculation:
D = max|F1(x) - F2(x)|. - Interpretation: A larger D indicates a greater divergence between the reference and production data.
- Threshold: If D exceeds a critical value (derived from the sample size and significance level α), the null hypothesis that the samples are drawn from the same distribution is rejected.
Drift Detection Workflow
In a continuous evaluation pipeline, the KS test is applied as a univariate drift detector on individual features.
- Reference Window: A baseline sample from the training data or a stable production period.
- Analysis Window: The most recent batch of production traffic.
- Alerting: A trigger is fired if the p-value falls below a strict threshold (e.g.,
p < 0.001), indicating a statistically significant shift that may degrade model performance.
Sensitivity to Sample Size
The KS test is highly sensitive to large sample sizes. In big data streaming contexts, even trivially small distributional shifts can produce a statistically significant p-value.
- Practical Drift: A statistically significant result does not always imply practical model degradation.
- Mitigation: Combine the KS statistic with a business impact metric like the Population Stability Index (PSI) to filter out noisy alerts that have no material effect on fraud detection accuracy.
Comparison with KL Divergence
Unlike Kullback-Leibler Divergence, the KS test is symmetric and does not require binning continuous data.
- Symmetry:
KS(P, Q) = KS(Q, P), unlike KL divergence. - No Binning: Operates directly on raw values, avoiding information loss from discretization.
- Trade-off: KL divergence can be more sensitive to differences in the tails of a distribution, whereas the KS test focuses on the median body of the data.
Two-Sample vs. One-Sample
The KS test has two primary variants for drift detection:
- Two-Sample KS Test: Compares two empirical distributions (e.g., training data vs. production data). This is the standard for data drift monitoring.
- One-Sample KS Test: Compares a sample against a specific theoretical distribution (e.g., testing if errors are normally distributed). This is less common in raw feature monitoring but useful for residual analysis.
KS Test vs. Other Drift Detection Methods
A comparison of the Kolmogorov-Smirnov test against other statistical methods used to detect distributional shifts in production fraud detection models.
| Feature | KS Test | Population Stability Index | Wasserstein Distance | Maximum Mean Discrepancy |
|---|---|---|---|---|
Test Type | Nonparametric | Information-theoretic | Metric-based | Kernel-based |
Measures | Maximum vertical distance between CDFs | Divergence across binned distributions | Earth mover's cost between distributions | Distance between mean embeddings in RKHS |
Sensitive to location shifts | ||||
Sensitive to scale shifts | ||||
Sensitive to shape changes | ||||
Requires binning | ||||
Handles multivariate data natively | ||||
Computational complexity | O(n log n) | O(n) | O(n³) exact; O(n²) approx | O(n²) |
Frequently Asked Questions
Clear, technically precise answers to the most common questions about the Kolmogorov-Smirnov test and its role in detecting feature drift in production fraud models.
The Kolmogorov-Smirnov test (KS test) is a nonparametric statistical test that determines whether two samples are drawn from the same underlying continuous distribution. It works by calculating the maximum vertical distance (the supremum) between two empirical cumulative distribution functions (ECDFs). This distance, known as the KS statistic (D), is then compared against a critical value derived from the Kolmogorov distribution. If the calculated D exceeds the critical value at a chosen significance level (typically α = 0.05), the null hypothesis—that both samples originate from the same distribution—is rejected. Unlike parametric tests such as the t-test, the KS test makes no assumptions about the underlying data distribution, making it highly versatile for monitoring arbitrary feature distributions in production machine learning pipelines. In the context of model drift monitoring, the two samples are typically a reference window (e.g., training data) and a current production window, and the test is applied independently to each input feature.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The KS test is a foundational tool for quantifying distributional shift. Explore the statistical metrics, drift types, and monitoring frameworks that form a complete model surveillance strategy.
Population Stability Index (PSI)
A symmetric metric that quantifies the shift in a variable's distribution over time by measuring the divergence between expected and actual probability bins. PSI is the industry standard for monitoring feature drift in financial services.
- Calculation: PSI = Σ (Actual% - Expected%) * ln(Actual% / Expected%)
- Interpretation: PSI < 0.1 indicates no significant shift; PSI > 0.25 signals major drift requiring investigation
- Relationship to KS: While KS measures maximum vertical distance between cumulative distributions, PSI measures information divergence across binned ranges
Data Drift vs. Concept Drift
Two distinct failure modes that the KS test helps diagnose. Data drift (covariate shift) occurs when input feature distributions change—detectable by applying the KS test to each feature independently. Concept drift occurs when the relationship between features and the target variable changes, requiring monitoring of prediction error rates.
- Example: A KS test on transaction amounts may reveal data drift if spending patterns shift seasonally
- Example: Concept drift occurs when previously fraudulent patterns become legitimate without feature distribution changes
- Diagnostic workflow: Use KS for feature-level monitoring; use Page-Hinkley or ADWIN for prediction error monitoring
Kullback-Leibler Divergence
An asymmetric statistical measure of how one probability distribution diverges from a second reference distribution. KL divergence is often preferred over KS when the direction of drift matters.
- Asymmetry: D_KL(P || Q) ≠ D_KL(Q || P), making it useful when the reference distribution has a specific meaning
- Limitation: Undefined when Q(x) = 0 but P(x) > 0, requiring smoothing in sparse regions
- Complement to KS: KS provides a bounded [0,1] interpretable statistic; KL provides an unbounded information-theoretic measure sensitive to tail behavior
Wasserstein Distance (Earth Mover's)
A metric measuring the minimum 'cost' to transform one distribution into another. Wasserstein distance captures geometric relationships between distributions that the KS test may miss.
- Advantage over KS: Sensitive to both location and shape changes, not just maximum vertical separation
- Interpretation: Literally the amount of probability mass multiplied by the distance it must be moved
- Use case: Particularly effective for monitoring continuous features like transaction amounts where the 'effort' to shift mass is meaningful
Maximum Mean Discrepancy (MMD)
A kernel-based statistical test that distinguishes two probability distributions by comparing their embeddings in a reproducing kernel Hilbert space. MMD generalizes the KS test to high-dimensional and structured data.
- Kernel flexibility: Using a Gaussian kernel allows MMD to detect any difference between distributions with sufficient data
- Multivariate capability: Unlike KS which is primarily univariate, MMD can test for joint distribution shifts across multiple features simultaneously
- Statistical power: Often more sensitive than KS for detecting subtle, complex distributional changes in high-dimensional feature spaces
Continuous Evaluation Framework
An automated MLOps process that persistently monitors deployed model performance against validation baselines. The KS test serves as a core statistical trigger within this framework.
- Pipeline components: Feature validation → KS-based drift detection → Performance metric calculation → Alert generation
- Threshold calibration: KS statistic thresholds must be tuned per feature to balance sensitivity against alert fatigue
- Automated response: When KS exceeds threshold, trigger champion-challenger evaluation or triggered retraining workflows to maintain fraud detection efficacy

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us