All problems
Population Stability Index
Problem
Compute the population stability index between expected and actual bin counts: normalize each list, clip each bin share to at least 1e-4, and sum (actual - expected) * ln(actual / expected).
Return 0.0 if either total is 0.
Hint
PSI is symmetric-ish divergence that grows when the actual distribution drifts from expected.
Test cases
case 1
in: [[20,30,50],[10,30,60]]
expected: 0.08754687373538998
case 2
in: [[50,50],[0,100]]
expected: 4.60431846666895
case 3
in: [[10,10],[10,10]]
expected: 0
Starter codePython
import math
def population_stability_index(expected_counts, actual_counts):
# Your code here
pass3 test cases · run your code against them in the editor