mcmc-synthesis-0.1.2.2: MCMC applied to probabilistic program synthesis

Safe HaskellNone

Language.Synthesis.Distribution

Synopsis

Documentation

data Distr a Source

Represents a discrete probability distribution.

Constructors

Distr 

Fields

sample :: forall g. RandomGen g => Rand g a

Sample a random item from the distribution.

logProbability :: a -> Double

Compute the log probability of a given value.

negativeInfinity :: DoubleSource

Negative infinity, the log of 0 probability.

sumByLogs :: [Double] -> DoubleSource

Computes (log . sum . map exp), with more numeric precision.

categorical :: Eq a => [(a, Double)] -> Distr aSource

A distribution from an (item, weight) list.

uniform :: Eq a => [a] -> Distr aSource

Uniform distribution.

randInt :: (Integral i, Random i) => (i, i) -> Distr iSource

A distribution over some integral type, inclusively between the 2 values.

replicate :: Int -> Distr a -> Distr [a]Source

Generate n independent draws from a distribution.

mix :: [(Distr a, Double)] -> Distr aSource

Given (distribution, weight) pairs, mix the distributions.

constant :: a -> Distr aSource

A distribution containing a single item.