Last active
May 8, 2020 01:56
-
-
Save usptact/c14fb8796b33e6dcf1cee6b66a4de20b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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