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

Control.Monad.Bayes.Weighted

Description

Weighted is an instance of MonadFactor. Apply a MonadDistribution transformer to obtain a MonadMeasure 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 #

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

Defined in Control.Monad.Bayes.Weighted

Methods

liftIO :: IO a -> 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 #

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 => 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 #

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

Defined in Control.Monad.Bayes.Weighted

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

Defined in Control.Monad.Bayes.Weighted

Methods

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

MonadDistribution m => MonadMeasure (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.

weighted . withWeight = id

weighted :: 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.

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

Compute the sample and discard the weight.

This operation introduces bias.

applyWeight :: MonadFactor 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.

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

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