Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-175

KS Statistic

Problem

Compute the KS statistic from binned counts: normalize both count lists, accumulate the CDFs, and return the maximum absolute gap between them.

Return 0.0 if either total is 0.

Hint

The KS statistic is the largest vertical distance between the two empirical CDFs.

Test cases

case 1
in: [[20,30,50],[10,30,60]]
expected: 0.1
case 2
in: [[50,50],[0,100]]
expected: 0.5
case 3
in: [[1,1],[1,1]]
expected: 0
case 4
in: [[],[]]
expected: 0
Starter codePython
def ks_statistic(expected_counts, actual_counts):
    # Your code here
    pass

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