deanie

An embedded probabilistic programming language.
git clone git://git.jtobin.io/deanie.git
Log | Files | Refs | README | LICENSE

BetaBernoulliRejection.hs (451B)


      1 
      2 module Main where
      3 
      4 import Control.Monad
      5 import Deanie
      6 import Model.BetaBernoulli as Model
      7 
      8 posterior :: Double -> Double -> Program Double
      9 posterior a b =
     10     grejection
     11       (\xs ys -> count xs == count ys)
     12       Model.observations (beta a b) bernoulli
     13   where
     14     count = length . filter id
     15 
     16 main :: IO ()
     17 main = do
     18   samples <- replicateM 1000 (sample (rvar (posterior 1 1)))
     19   mapM_ print samples
     20 
     21   putStrLn "\nestimate:"
     22   print (mc samples)
     23