module Main where import Data.Array (Array, accumArray, elems, Ix, inRange) import System.Random (RandomGen, newStdGen, random) histogram bounds bins = accumArray (+) 0 bounds [(x, 1) | x <- bins, inRange bounds x] bernoulli p = do x <- state random binomial count p = test bias nails tries = do gen <- newStdGen let bins = simulate gen tries $ binomial nails bias let h = histogram (0, nails) bins print $ elems h main = test 0.5 100 10000
Standard input is empty
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,7,16,31,49,68,111,153,220,281,364,500,581,650,718,811,812,796,726,661,565,503,427,310,207,169,88,72,39,21,25,6,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]