mwc-probability

Sampling function-based probability distributions.
git clone git://git.jtobin.io/mwc-probability.git
Log | Files | Refs | README | LICENSE

README.md (1371B)


      1 # mwc-probability
      2 
      3 [![Hackage Version](https://img.shields.io/hackage/v/mwc-probability.svg)](http://hackage.haskell.org/package/mwc-probability)
      4 [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jtobin/mwc-probability/blob/master/LICENSE)
      5 
      6 Sampling function-based probability distributions.
      7 
      8 A simple probability distribution type, where distributions are characterized
      9 by sampling functions.
     10 
     11 This implementation is a thin layer over `mwc-random`, which handles RNG
     12 state-passing automatically by using a `PrimMonad` like `IO` or `ST s` under
     13 the hood.
     14 
     15 Examples
     16 --------
     17 
     18 * Transform a distribution's support while leaving its density structure
     19 invariant:
     20 
     21       -- uniform over [0, 1] transformed to uniform over [1, 2]
     22       succ <$> uniform
     23 
     24 * Sequence distributions together using bind:
     25 
     26       -- a beta-binomial composite distribution
     27       beta 1 10 >>= binomial 10
     28 
     29 * Use do-notation to build complex joint distributions from composable,
     30   local conditionals:
     31 
     32       hierarchicalModel = do
     33         [c, d, e, f] <- replicateM 4 (uniformR (1, 10))
     34         a <- gamma c d
     35         b <- gamma e f
     36         p <- beta a b
     37         n <- uniformR (5, 10)
     38         binomial n p
     39 
     40 Check out the haddock-generated docs on
     41 [Hackage](https://hackage.haskell.org/package/mwc-probability) for other
     42 examples.
     43 
     44 ## Etc.
     45 
     46 PRs and issues welcome.
     47