All problems
Bayesian Online Changepoint Step
Problem
Perform one Bayesian online changepoint detection update. Given current run-length probabilities, a constant hazard rate, and the predictive probability of the new observation, form the changepoint term hazard * predictive and the growth terms run_prob * (1 - hazard) * predictive, then normalize.
Return the new run-length probability vector (one element longer). Return an empty list for empty input.
Hint
Index 0 is the probability that a changepoint just happened.
Test cases
case 1
in: [[0.8,0.2],0.1,0.5]
expected: [0.1,0.7200000000000001,0.18000000000000002]
case 2
in: [[1],0.05,1]
expected: [0.05,0.95]
case 3
in: [[0.5,0.3,0.2],0,1]
expected: [0,0.5,0.3,0.2]
case 4
in: [[0.5,0.5],1,0.5]
expected: [1,0,0]
Starter codePython
def bayesian_online_changepoint_step(run_probs, hazard, predictive_prob):
# Your code here
pass4 test cases · run your code against them in the editor