Premium problem63. Which Day Was It?

Medium Locked

Someone always turns up to an activity on the days listed in always_days, and on any other day of the week they turn up independently with probability p. Days are numbered 0 to 6 and each is equally likely a priori.

You are told only that they attended. Return the probability the day was target.

Bayes with a uniform prior, so the answer is just that day's attendance probability over the sum across all seven days.

Input

always_days = [1, 3]
p = 0.2
target = 1

Output

0.33333333333333326

Premium problem

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

Implement solve(...)