Processing math: 100%
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.Population

Description

Population turns a single sample into a collection of weighted samples.

Synopsis

Documentation

data Population m a Source #

A collection of weighted samples, or particles.

Instances

Instances details
MonadTrans Population Source # 
Instance details

Defined in Control.Monad.Bayes.Population

Methods

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

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

Defined in Control.Monad.Bayes.Population

Methods

liftIO :: IO a -> Population m a #

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

Defined in Control.Monad.Bayes.Population

Methods

pure :: a -> Population m a #

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

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

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

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

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

Defined in Control.Monad.Bayes.Population

Methods

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

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

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

Defined in Control.Monad.Bayes.Population

Methods

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

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

return :: a -> Population m a #

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

Defined in Control.Monad.Bayes.Population

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

Defined in Control.Monad.Bayes.Population

Methods

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

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

Defined in Control.Monad.Bayes.Population

population :: Population m a -> m [(a, Log Double)] Source #

Explicit representation of the weighted sample with weights in the log domain.

runPopulation :: Population m a -> m [(a, Log Double)] Source #

deprecated synonym

Explicit representation of the weighted sample with weights in the log domain.

explicitPopulation :: Functor m => Population m a -> m [(a, Double)] Source #

Explicit representation of the weighted sample.

fromWeightedList :: Monad m => m [(a, Log Double)] -> Population m a Source #

Initialize Population with a concrete weighted sample.

spawn :: Monad m => Int -> Population m () Source #

Increase the sample size by a given factor. The weights are adjusted such that their sum is preserved. It is therefore safe to use spawn in arbitrary places in the program without introducing bias.

multinomial :: MonadDistribution m => Vector Double -> m [Int] Source #

Multinomial sampler. Sample from 0,,n1 n times drawn at random according to the weights where n is the length of vector of weights.

resampleMultinomial :: MonadDistribution m => Population m a -> Population m a Source #

Resample the population using the underlying monad and a multinomial resampling scheme. The total weight is preserved.

systematic :: Double -> Vector Double -> [Int] Source #

Systematic sampler. Sample n values from (0,1] as follows u(1)U(0,1n]u(i)=u(1)+i1n,i=2,3,,n and then pick integers m according to Q(m1)<u(n)Q(m) where Q(m)=mk=1w(k) and w(k) are the weights. See also Comparison of Resampling Schemes for Particle Filtering.

resampleSystematic :: MonadDistribution m => Population m a -> Population m a Source #

Resample the population using the underlying monad and a systematic resampling scheme. The total weight is preserved.

stratified :: MonadDistribution m => Vector Double -> m [Int] Source #

Stratified sampler.

Sample n values from (0,1] as follows u(i)U(i1n,in],i=1,2,,n and then pick integers m according to Q(m1)<u(n)Q(m) where Q(m)=mk=1w(k) and w(k) are the weights.

The conditional variance of stratified sampling is always smaller than that of multinomial sampling and it is also unbiased - see Comparison of Resampling Schemes for Particle Filtering.

resampleStratified :: MonadDistribution m => Population m a -> Population m a Source #

Resample the population using the underlying monad and a stratified resampling scheme. The total weight is preserved.

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

Separate the sum of weights into the Weighted transformer. Weights are normalized after this operation.

pushEvidence :: MonadFactor m => Population m a -> Population m a Source #

Push the evidence estimator as a score to the transformed monad. Weights are normalized after this operation.

proper :: MonadDistribution m => Population m a -> Weighted m a Source #

A properly weighted single sample, that is one picked at random according to the weights, with the sum of all weights.

evidence :: Monad m => Population m a -> m (Log Double) Source #

Model evidence estimator, also known as pseudo-marginal likelihood.

hoist :: Monad n => (forall x. m x -> n x) -> Population m a -> Population n a Source #

Applies a transformation to the inner monad.

collapse :: MonadMeasure m => Population m a -> m a Source #

Picks one point from the population and uses model evidence as a score in the transformed monad. This way a single sample can be selected from a population without introducing bias.

popAvg :: Monad m => (a -> Double) -> Population m a -> m Double Source #

Population average of a function, computed using unnormalized weights.