Copyright | © 2016-2017 George Steel and Peter Jurgec |
---|---|
License | GPL-2+ |
Maintainer | george.steel@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Data structures and functions for counting and probability.
- newtype Multicount = MC {}
- getCounts :: Multicount -> [Int]
- consMC :: Sum Int -> Multicount -> Multicount
- singleMC :: Sum Int -> Multicount
- fromMC :: Multicount -> Vec
- data Expectation v = Exp {}
- normalizeExp :: RingModule Double v => Expectation v -> v
- data Cdf a
- massToCdf :: [(a, Double)] -> Cdf a
- sampleCdf :: (RandomGen g, MonadState g m) => Cdf a -> m a
- uniformSample :: Cdf a -> Int -> [(a, Int)]
- upperConfidenceOE :: Double -> Double -> Double
Counting
newtype Multicount Source #
Monoid holding a list of integer counters which are summed independently
consMC :: Sum Int -> Multicount -> Multicount Source #
Add a new count to the head of the list
fromMC :: Multicount -> Vec Source #
Convert the counts to coordinates
Expectations
data Expectation v Source #
Expectation semiring as described by Eisner.
Represents an events contribution to the total expectation of a vector-valued variable. Addition takes the union of mutually exclusive events and multiplication either takes the intersection fo independent events or applies a conditional probability.
As a simple example, the expectation of the total value from rolling a 2 on a 6 sided die would be Exp (16) (26)
.
PackedDFA ExpDoubleDFST (Expectation Double) Source # | |
PackedDFA ExpVecDFST (Expectation Vec) Source # | |
Eq v => Eq (Expectation v) Source # | |
Show v => Show (Expectation v) Source # | |
RingModule Double v => Semiring (Expectation v) Source # | |
RingModule Double v => Additive (Expectation v) Source # | |
normalizeExp :: RingModule Double v => Expectation v -> v Source #
Get the expectation conditional on the event actually occurring.
Sampling and Distributions
Cumulative distribution table that can be sampled easily.
massToCdf :: [(a, Double)] -> Cdf a Source #
Generate a CDF which from a list of outcomes and their relative probabilities (their sum will eb normalized and does not have to be 1).
sampleCdf :: (RandomGen g, MonadState g m) => Cdf a -> m a Source #
Sample a random variable according to a Cdf
, gets the random generator state from the monad.