TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
←

121. KS Test Drift Detection

Medium

Implement the two-sample KS statistic to detect distribution drift between a reference dataset and a current production dataset.

Signature: def ks_statistic(reference: list, current: list) -> float

The KS statistic is the maximum absolute difference between the empirical CDFs of the two samples evaluated over their combined sorted points.

Example:

  • reference = [1, 2, 3, 4, 5]
  • current = [3, 4, 5, 6, 7]
  • Output: 0.4 (max gap between empirical CDFs)

Math

D=xsup​∣F1​(x)−F2​(x)∣

Asked at

NumPy

import numpy as np

 

def ks_statistic(...):

    pass

🔒

Premium problem

Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.

Upgrade to PremiumBack to problems

Already premium?