monad-bayes-0.1.1.0: A library for probabilistic programming.
Copyright(c) Adam Scibior 2015-2020
LicenseMIT
Maintainerleonhard.markert@tweag.io
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Bayes.Weighted

Description

Weighted is an instance of MonadCond. Apply a MonadSample transformer to obtain a MonadInfer that can execute probabilistic models.

Synopsis

Documentation

data Weighted m a Source #

Execute the program using the prior distribution, while accumulating likelihood.

Instances

Instances details
MonadTrans Weighted Source # 
Instance details

Defined in Control.Monad.Bayes.Weighted

Methods

lift :: Monad m => m a -> Weighted m a #

Monad m => Monad (Weighted m) Source # 
Instance details

Defined in Control.Monad.Bayes.Weighted

Methods

(>>=) :: Weighted m a -> (a -> Weighted m b) -> Weighted m b #

(>>) :: Weighted m a -> Weighted m b -> Weighted m b #

return :: a -> Weighted m a #

Functor m => Functor (Weighted m) Source # 
Instance details

Defined in Control.Monad.Bayes.Weighted

Methods

fmap :: (a -> b) -> Weighted m a -> Weighted m b #

(<$) :: a -> Weighted m b -> Weighted m a #

Monad m => Applicative (Weighted m) Source # 
Instance details

Defined in Control.Monad.Bayes.Weighted

Methods

pure :: a -> Weighted m a #

(<*>) :: Weighted m (a -> b) -> Weighted m a -> Weighted m b #

liftA2 :: (a -> b -> c) -> Weighted m a -> Weighted m b -> Weighted m c #

(*>) :: Weighted m a -> Weighted m b -> Weighted m b #

(<*) :: Weighted m a -> Weighted m b -> Weighted m a #

MonadIO m => MonadIO (Weighted m) Source # 
Instance details

Defined in Control.Monad.Bayes.Weighted

Methods

liftIO :: IO a -> Weighted m a #

MonadSample m => MonadInfer (Weighted m) Source # 
Instance details

Defined in Control.Monad.Bayes.Weighted

Monad m => MonadCond (Weighted m) Source # 
Instance details

Defined in Control.Monad.Bayes.Weighted

Methods

score :: Log Double -> Weighted m () Source #

MonadSample m => MonadSample (Weighted m) Source # 
Instance details

Defined in Control.Monad.Bayes.Weighted

withWeight :: Monad m => m (a, Log Double) -> Weighted m a Source #

Embed a random variable with explicitly given likelihood.

runWeighted . withWeight = id

runWeighted :: Functor m => Weighted m a -> m (a, Log Double) Source #

Obtain an explicit value of the likelihood for a given value.

extractWeight :: Functor m => Weighted m a -> m (Log Double) Source #

Compute the weight and discard the sample.

prior :: Functor m => Weighted m a -> m a Source #

Compute the sample and discard the weight.

This operation introduces bias.

flatten :: Monad m => Weighted (Weighted m) a -> Weighted m a Source #

Combine weights from two different levels.

applyWeight :: MonadCond m => Weighted m a -> m a Source #

Use the weight as a factor in the transformed monad.

hoist :: (forall x. m x -> n x) -> Weighted m a -> Weighted n a Source #

Apply a transformation to the transformed monad.