Safe Haskell | None |
---|---|
Language | Haskell98 |
- class Sampleable d m t where
- sample :: (Sampleable d m t, MonadRandom m) => d t -> m t
- sampleState :: (Sampleable d (State s) t, MonadRandom (State s)) => d t -> s -> (t, s)
- sampleStateT :: (Sampleable d (StateT s m) t, MonadRandom (StateT s m)) => d t -> s -> m (t, s)
Documentation
class Sampleable d m t where Source #
A typeclass allowing Distribution
s and RVar
s to be sampled. Both may
also be sampled via runRVar
or runRVarT
, but I find it psychologically
pleasing to be able to sample both using this function, as they are two
separate abstractions for one base concept: a random variable.
sampleFrom :: RandomSource m s => s -> d t -> m t Source #
Directly sample from a distribution or random variable, using the given source of entropy.
Distribution d t => Sampleable d m t Source # | |
Lift m n => Sampleable (RVarT m) n t Source # | |
sample :: (Sampleable d m t, MonadRandom m) => d t -> m t Source #
Sample a random variable using the default source of entropy for the monad in which the sampling occurs.
sampleState :: (Sampleable d (State s) t, MonadRandom (State s)) => d t -> s -> (t, s) Source #
Sample a random variable in a "functional" style. Typical instantiations
of s
are System.Random.StdGen
or System.Random.Mersenne.Pure64.PureMT
.
sampleStateT :: (Sampleable d (StateT s m) t, MonadRandom (StateT s m)) => d t -> s -> m (t, s) Source #
Sample a random variable in a "semi-functional" style. Typical instantiations
of s
are System.Random.StdGen
or System.Random.Mersenne.Pure64.PureMT
.