Re:Ask HN: What's your speciality, and what's your "FizzBuzz...
by mag487 on Thursday January 02, 2014 @02:47PM
(#7001771)
It may be a useful sanity check to simulate the experiment multiple times to see the result:
[ Parent
| on HN ]
Re:Ask HN: What's your speciality, and what's your "FizzBuzz...
by jules on Thursday January 02, 2014 @03:52PM
(#7002188)
What's really interesting is that there are probabilistic programming languages where you can write a program that does a simulation just like you did, but the execution engine can compute the probabilities exactly and much faster too. It does this by computing along all possible paths in the program, and keeping track of the probability mass of each path, and then summing them all up in the end.
http://en.wikipedia.org/wiki/Probabilistic_programming_langu...
Re:Ask HN: What's your speciality, and what's your "FizzBuzz...
by crntaylor on Friday January 03, 2014 @10:11AM
(#7005758)
Completely shameless plug for a tiny probabilistic programming language that I wrote as an embedded DSL in Haskell:
https://github.com/chris-taylor/hs-probability
The code that solves this problem is:
solve = do
coin <- choose (999/1000) fair biased
tosses <- replicateM 10 coin
condition (tosses == replicate 10 Head)
nextToss <- coin
return nextToss
where
fair = choose (1/2) Head Tail
biased = certainly Head