License | GPL-3 |
---|---|
Maintainer | hackage@mail.kevinl.io |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
This module contains the types used for the stochastic package.
WARNING: In its current state, care should be taken when using discrete distributions as it is never checked that the probabilities sum to 1. As is, execution of sampling may fail at run-time if probabilities aren't normalized.
- data Distribution a where
- Normal :: Mean -> StDev -> Distribution Double
- Bernoulli :: Double -> Distribution Bool
- Discrete :: [(a, Double)] -> Distribution a
- Uniform :: [a] -> Distribution a
- Certain :: a -> Distribution a
- class Sampleable d where
- newtype Sample g d a = Sample {
- runSample :: (RandomGen g, Sampleable d) => g -> (d a, g)
- type StochProcess = WriterT (Seq Double) (Sample StdGen Distribution) Double
- type Sampler a = Sample StdGen Distribution a
- type Mean = Double
- type StDev = Double
Documentation
data Distribution a where Source #
Datatype representing parameterized probability distributions over values of type a. GADTs are used to restrict types of certain distributions (e.g. normal distributions can only be defined over floating point numbers)
Normal :: Mean -> StDev -> Distribution Double | |
Bernoulli :: Double -> Distribution Bool | |
Discrete :: [(a, Double)] -> Distribution a | |
Uniform :: [a] -> Distribution a | |
Certain :: a -> Distribution a |
Sampleable Distribution Source # |
|
Show a => Show (Distribution a) Source # | Show instance for |
class Sampleable d where Source #
Class of types from which samples can be obtained.
certainDist :: a -> d a Source #
Constructor for a datatype from which we always sample the same value.
sampleFrom :: RandomGen g => d a -> g -> (a, g) Source #
Sampleable Distribution Source # |
|
Sample
monad containing a random number generator plus a type from which
we can sample values of type a
Sample | |
|
(RandomGen g, Sampleable d) => Monad (Sample g d) Source # | Monad instance for Sample. |
(RandomGen g, Sampleable s) => Functor (Sample g s) Source # | Trivial |
(RandomGen g, Sampleable s) => Applicative (Sample g s) Source # | Trivial |
type StochProcess = WriterT (Seq Double) (Sample StdGen Distribution) Double Source #
Monad that represents a stochastic process. It allows us to record numeric values as we sample.
type Sampler a = Sample StdGen Distribution a Source #
Type synonym for shorter type annotations for Sample
.