All problems
Log-Odds Bayesian Update
Problem
In log-odds form, Bayes' rule becomes additive: log posterior odds = log prior odds + sum of the log likelihood ratios. Given the log prior odds and a list of log likelihood ratios, return the log posterior odds. An empty list leaves the prior odds unchanged.
Hint
Multiplying odds by likelihood ratios becomes adding their logarithms.
Test cases
case 1
in: [0,[1]]
expected: 1
case 2
in: [0,[]]
expected: 0
case 3
in: [-2,[0.5,0.5]]
expected: -1
case 4
in: [1.5,[-0.5,2,-1]]
expected: 2
case 5
in: [-1,[0.25,-0.75]]
expected: -1.5
Starter codePython
def log_odds_bayesian_update(log_prior_odds, log_likelihood_ratios):
# Your code here
pass5 test cases · run your code against them in the editor