Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-417

Population Stability Index Bins

Problem

The population stability index sums (actual_pct - expected_pct) * ln(actual_pct / expected_pct) over bins, with a small epsilon guard convention here: bins with either share at zero contribute zero.

Given the expected and actual proportions, return the PSI.

Hint

Identical distributions give zero drift.

Test cases

case 1
in: [[0.5,0.5],[0.5,0.5]]
expected: 0
case 2
in: [[0.5,0.5],[0.6,0.4]]
expected: 0.04054651081081642
case 3
in: [[0.25,0.75],[0,1]]
expected: 0.07192051811294521
Starter codePython
def population_stability_index(expected, actual):
    # Your code here
    pass

3 test cases · run your code against them in the editor