Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-341

Retention Curve Rates

Problem

Compute a cohort retention curve as fractions of the initial cohort size: rates[i] = cohort_sizes[i] / cohort_sizes[0]. Return [] when the cohort is empty or starts at 0.

Hint

Normalizing by the period-0 size makes cohorts of different sizes directly comparable.

Test cases

case 1
in: [[100,60,30,15]]
expected: [1,0.6,0.3,0.15]
case 2
in: [[50,50]]
expected: [1,1]
case 3
in: [[0,5]]
expected: []
case 4
in: [[]]
expected: []
Starter codePython
def retention_curve(cohort_sizes):
    # Your code here
    pass

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