Last active
July 24, 2020 17:02
-
-
Save youqad/98a55a6c46b76a0e4d28f0b240237052 to your computer and use it in GitHub Desktop.
WebPPL: Monty Hall (Solution 2: without loss of generality, suppose that we originally pick the 1st door and Monty opens the 2nd one)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MontyHall = function () { | |
var car = randomInteger({n: 3}) | |
var our_choice = randomInteger({n: 3}) | |
var monty = categorical({vs: filter( | |
function(d){return d != car & d != our_choice }, [0,1,2])}) | |
condition((our_choice == 0) & (monty == 1)) | |
return car == 2 ? "change wins": "keep wins" | |
} | |
viz(Infer(MontyHall)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment