monad-bayes-1.3.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

WeightedT is an instance of MonadFactor. Apply a MonadDistribution transformer to obtain a MonadMeasure that can execute probabilistic models.

Synopsis

Documentation

data WeightedT m a Source #

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

Instances

Instances details
MonadTrans WeightedT Source # 
Instance details

Defined in Control.Monad.Bayes.Weighted

Methods

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

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

Defined in Control.Monad.Bayes.Weighted

Methods

liftIO :: IO a -> WeightedT m a #

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

Defined in Control.Monad.Bayes.Weighted

Methods

pure :: a -> WeightedT m a #

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

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

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

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

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

Defined in Control.Monad.Bayes.Weighted

Methods

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

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

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

Defined in Control.Monad.Bayes.Weighted

Methods

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

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

return :: a -> WeightedT m a #

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

Defined in Control.Monad.Bayes.Weighted

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

Defined in Control.Monad.Bayes.Weighted

Methods

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

MonadDistribution m => MonadMeasure (WeightedT m) Source # 
Instance details

Defined in Control.Monad.Bayes.Weighted

weightedT :: Monad m => m (a, Log Double) -> WeightedT m a Source #

Embed a random variable with explicitly given likelihood.

runWeightedT . weightedT = id

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

Compute the weight and discard the sample.

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

Compute the sample and discard the weight.

This operation introduces bias.

applyWeight :: MonadFactor m => WeightedT m a -> m a Source #

Use the weight as a factor in the transformed monad.

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

Apply a transformation to the transformed monad.

runWeightedT :: WeightedT m a -> m (a, Log Double) Source #

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