Copyright | (c) Adam Scibior 2015-2020 |
---|---|
License | MIT |
Maintainer | leonhard.markert@tweag.io |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Weighted
is an instance of MonadFactor
. Apply a MonadDistribution
transformer to
obtain a MonadMeasure
that can execute probabilistic models.
Synopsis
- data Weighted m a
- withWeight :: Monad m => m (a, Log Double) -> Weighted m a
- weighted :: Weighted m a -> m (a, Log Double)
- extractWeight :: Functor m => Weighted m a -> m (Log Double)
- unweighted :: Functor m => Weighted m a -> m a
- applyWeight :: MonadFactor m => Weighted m a -> m a
- hoist :: (forall x. m x -> n x) -> Weighted m a -> Weighted n a
- runWeighted :: Weighted m a -> m (a, Log Double)
Documentation
Execute the program using the prior distribution, while accumulating likelihood.
Instances
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.