Premium problem77. Which Factory Made the Defect?

Medium Locked

shares[i] is the fraction of total output from factory i and defect_rates[i] is its defect rate. You are holding a defective item. Return the posterior probability it came from each factory, as a list.

A factory with a small share can still be the likely culprit if its defect rate is bad enough. That trade-off is the whole point.

Input

shares = [0.5, 0.3, 0.2]
defect_rates = [0.01, 0.02, 0.05]

Output

[0.23809523809523808, 0.2857142857142857, 0.4761904761904763]

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)