Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-095

Changepoint Penalty BIC

Problem

Compute the BIC-style penalty for adding a changepoint with p parameters: p * ln(n) for n observations.

Return 0.0 if n or p is not positive.

Hint

The penalty grows with sample size, but only logarithmically.

Test cases

case 1
in: [100,1]
expected: 4.605170185988092
case 2
in: [100,3]
expected: 13.815510557964275
case 3
in: [1,2]
expected: 0
case 4
in: [10,0]
expected: 0
Starter codePython
import math
def changepoint_penalty_bic(n, p):
    # Your code here
    pass

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