Copyright | (c) Adam Scibior 2015-2020 |
---|---|
License | MIT |
Maintainer | leonhard.markert@tweag.io |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Weighted
is an instance of MonadCond
. Apply a MonadSample
transformer to
obtain a MonadInfer
that can execute probabilistic models.
Synopsis
- data Weighted m a
- withWeight :: Monad m => m (a, Log Double) -> Weighted m a
- runWeighted :: Functor m => Weighted m a -> m (a, Log Double)
- extractWeight :: Functor m => Weighted m a -> m (Log Double)
- prior :: Functor m => Weighted m a -> m a
- flatten :: Monad m => Weighted (Weighted m) a -> Weighted m a
- applyWeight :: MonadCond m => Weighted m a -> m a
- hoist :: (forall x. m x -> n x) -> Weighted m a -> Weighted n a
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.
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.