Premium problem80. Which Coin Did You Pick?

Medium Locked

One of two coins is chosen with equal probability: coin 1 lands heads with probability p1, coin 2 with p2. You flip the chosen coin and record observations, a list of 1 for heads and 0 for tails. Return (posterior_1, posterior_2).

Each coin's likelihood is the product over the flips; the priors are equal, so they cancel out of the ratio and only the likelihoods decide it.

Input

p1 = 0.5
p2 = 0.9
observations = [1, 1, 1, 1]

Output

(0.0869746729752296, 0.9130253270247704)

Premium problem

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

Implement solve(...)