A prize is hidden uniformly at random behind one of n_doors doors (numbered from 0). You pick door chosen. The host then opens the doors in the list opened (none of them is your door) and every opened door is empty. Compute the posterior probability that the prize is behind each door.
What the opened doors tell you depends on how the host chooses them, so implement both host models:
host="knows": the host knows where the prize is and opens k = len(opened) doors chosen uniformly at random among the doors that are neither yours nor the prize door.host="random": the host opens k doors chosen uniformly at random among the doors that are not yours, without knowing where the prize is; in this game they all happened to be empty.Implement monty_posterior(n_doors, chosen, opened, host) returning a list of n_doors floats , where is "the prize is behind door ". Use Bayes' rule with the uniform prior : write down the likelihood of the observed data under each for the given host model, multiply by the prior and normalize.
You may assume opened does not contain chosen, has no repeats, and k <= n_doors - 2.