Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-024

Total Probability

Problem

Total probability over a partition of hypotheses.

Given lists of prior probabilities and conditional probabilities, return sum(priors[i] * conditionals[i]). The two lists are assumed to have the same length.

Hint

Weight each conditional probability by its prior.

Test cases

case 1
in: [[0.3,0.7],[0.2,0.9]]
expected: 0.69
case 2
in: [[1],[0.4]]
expected: 0.4
case 3
in: [[0.5,0.5],[1,0]]
expected: 0.5
case 4
in: [[],[]]
expected: 0
Starter codePython
def total_probability(priors, conditionals):
    # Your code here
    pass

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