Skip to content

Instantly share code, notes, and snippets.

@usptact
Last active May 8, 2020 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usptact/c14fb8796b33e6dcf1cee6b66a4de20b to your computer and use it in GitHub Desktop.
Save usptact/c14fb8796b33e6dcf1cee6b66a4de20b to your computer and use it in GitHub Desktop.
// Two balls in the bag:
// (1) fifty/fifty red (true) or green (false)
// (2) 100% red
//
// Process:
// - pull out the first ball and observe it is red
// - Question: what is the probability the remaining ball is red too?
var model = function() {
var b1 = flip(0.5)
var b2 = flip(1)
var pick = flip(0.5)
if (pick == true) {
condition(b1 == true)
return b2
} else {
condition(b2 == true)
return b1
}
}
var dist = Infer(model)
viz(dist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment