All problems
Changepoint Posterior Probability
Problem
Compute the posterior probability of a changepoint from a prior probability p and two likelihoods: p * L_change / (p * L_change + (1 - p) * L_no_change).
Return 0.0 when the denominator is zero.
Hint
This is Bayes rule written as a weighted average of the two hypotheses.
Test cases
case 1
in: [0.1,0.9,0.2]
expected: 0.33333333333333337
case 2
in: [0.5,0.5,0.5]
expected: 0.5
case 3
in: [0.2,0.8,0.1]
expected: 0.6666666666666666
case 4
in: [0,0.9,0.2]
expected: 0
case 5
in: [0.3,0,0.5]
expected: 0
Starter codePython
def changepoint_posterior_probability(prior, lik_change, lik_no_change):
# Your code here
pass5 test cases · run your code against them in the editor