All problems
Two Class Posterior from Likelihoods
Problem
For two classes with prior P(C1) = prior and likelihoods l1, l2, the posteriors are proportional to [prior l1, (1 - prior) l2] normalized to sum to one.
Given the prior and the two likelihoods, return [P(C1 | x), P(C2 | x)].
Hint
Multiply prior by likelihood, then normalize.
Test cases
case 1
in: [0.5,0.8,0.2]
expected: [0.8,0.2]
case 2
in: [0.3,0.9,0.1]
expected: [0.7941176470588235,0.20588235294117643]
case 3
in: [0.5,0.5,0.5]
expected: [0.5,0.5]
Starter codePython
def two_class_posterior_from_likelihoods(prior, l1, l2):
# Your code here
pass3 test cases · run your code against them in the editor