{-# LANGUAGE ExtendedDefaultRules #-}importLazyPPLimportDistrimportData.List-- Lazy PPL example. We avoid plotting libraries.model::MeasBoolmodel=do-- Prior: -- 1:6 is Sunday.sunday<-sample$bernoulli(1/7)-- Update: -- On Sunday buses are distributed as Poisson(3) in one hour.-- On other days, buses are distributed as Poisson(10) in one hour.-- I have observed 4 buses in one hour.score$poissonPdf(ifsundaythen3else10)4-- Posterior: -- What is the probability of Sunday?returnsundayprobSunday::IODoubleprobSunday=doxws<-mh1modelletresolution=3000lettrues=length$filter(==True)$mapfst$takeresolutionxwsreturn$(fromIntegraltrues::Double)/(fromIntegralresolution::Double)-- PARTIAL MARKOVobserve::Bool->Meas()observefact=score$iffactthen0.999else0.001-- NEWCOMB'S PROBLEMnewcomb::Bool->MeasDoublenewcombx=do-- Prioractor<-sample$bernoulli(1/2)predictor<-sample$bernoulli(1/2)-- Observationsobserve$actor==xobserve$predictor==actor-- Posteriorreturn$outcomeactorpredictorwhereoutcome::Bool->Bool->Double-- oneboxingoutcomeTrueTrue=1000outcomeTrueFalse=0-- twoboxingoutcomeFalseTrue=1001outcomeFalseFalse=1execDouble::MeasDouble->IODoubleexecDoublemodel=doxws<-mh1modelletresolution=10000return$(\x->x/(fromIntegralresolution))$sum$mapfst(takeresolutionxws)-- probNewcomb :: IO probNewcombx=doxws<-mh1(newcombx)letresolution=10000return$(\x->x/(fromIntegralresolution))$sum$mapfst(takeresolutionxws)