| Copyright | (c) Adam Scibior 2015-2020 |
|---|---|
| License | MIT |
| Maintainer | leonhard.markert@tweag.io |
| Stability | experimental |
| Portability | GHC |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Control.Monad.Bayes.Traced.Static
Description
Synopsis
Documentation
A tracing monad where only a subset of random choices are traced.
The random choices that are not to be traced should be lifted from the transformed monad.
Instances
mhStep :: MonadDistribution m => Traced m a -> Traced m a Source #
A single step of the Trace Metropolis-Hastings algorithm.
mh :: MonadDistribution m => Int -> Traced m a -> m [a] Source #
Full run of the Trace Metropolis-Hastings algorithm with a specified number of steps. Newest samples are at the head of the list.
For example:
- I have forgotten what day it is.
- There are ten buses per hour in the week and three buses per hour at the weekend.
- I observe four buses in a given hour.
- What is the probability that it is the weekend?
>>>:{let bus = do x <- bernoulli (2/7) let rate = if x then 3 else 10 factor $ poissonPdf rate 4 return x mhRunBusSingleObs = do let nSamples = 2 sampleIOfixed $ unweighted $ mh nSamples bus in mhRunBusSingleObs :} [True,True,True]
Of course, it will need to be run more than twice to get a reasonable estimate.