Compare a production histogram with a reference histogram using total variation distance. First normalize each list of counts into a probability distribution. Then compute:
DTV(P,Q)=21i∑∣pi−qi∣Here, pi and qi are the normalized probabilities for bin i. Drift is detected only when the score is strictly greater than the threshold. Return a dictionary containing the score as a float and the drift_detected flag as a Boolean.
Input: reference_counts = [50, 50], production_counts = [55, 45], threshold = 0.1
Output: {"score": 0.05, "drift_detected": false}
Explanation: The absolute probability differences sum to 0.1, so TVD is 0.05.
Input: reference_counts = [50, 50], production_counts = [90, 10], threshold = 0.1
Output: {"score": 0.4, "drift_detected": true}
Divide every bin count by the total count of its histogram.
Sum the absolute differences between matching probabilities, then multiply by one half.
Accepts: array
Accepts: array
Accepts: number
Compare a production histogram with a reference histogram using total variation distance. First normalize each list of counts into a probability distribution. Then compute:
DTV(P,Q)=21i∑∣pi−qi∣Here, pi and qi are the normalized probabilities for bin i. Drift is detected only when the score is strictly greater than the threshold. Return a dictionary containing the score as a float and the drift_detected flag as a Boolean.
Input: reference_counts = [50, 50], production_counts = [55, 45], threshold = 0.1
Output: {"score": 0.05, "drift_detected": false}
Explanation: The absolute probability differences sum to 0.1, so TVD is 0.05.
Input: reference_counts = [50, 50], production_counts = [90, 10], threshold = 0.1
Output: {"score": 0.4, "drift_detected": true}
Divide every bin count by the total count of its histogram.
Sum the absolute differences between matching probabilities, then multiply by one half.
Accepts: array
Accepts: array
Accepts: number