Last active
July 25, 2020 11:11
-
-
Save youqad/bdf4fe884cac5b5d8639e5060c88baa7 to your computer and use it in GitHub Desktop.
WebPPL: Monty Hall (Solution 1: doesn't resort to any "without loss of generality" argument)
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 all_doors_but = function (d1, d2) { | |
return filter(function(d){return d != d1 & d != d2 }, [0,1,2]) | |
} | |
var monty = categorical({vs: all_doors_but(car, our_choice)}) | |
var door_not_opened = all_doors_but(monty, our_choice)[0] | |
return car == door_not_opened ? "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