Skip to content

Instantly share code, notes, and snippets.

@youqad
Last active July 24, 2020 17:02
Show Gist options
  • Save youqad/98a55a6c46b76a0e4d28f0b240237052 to your computer and use it in GitHub Desktop.
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)
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