A suite of Haskell libraries for representing, manipulating, and sampling random variables


Keywords
math, public-domain, Propose Tags, Index, Quick Jump, Data.RVar, More info, rvar-0.3.0.2.tar.gz, browse, Package description, Package maintainers, BertramFelgenhauer, DominicSteinitz, JamesCook, edit package information , 0.2.0.4, 0.2.0.6, 0.3.0.0, 0.3.0.1, 0.3.0.2
License
Other
Install
cabal install rvar-0.3.0.2

Documentation

Status

Language CircleCI
GitHub top language Build Status

Random-fu

Random-number generation based on modeling random variables as first-class entities. This library currently consists of 3 major parts:

rvar

This package defines the central datatype of the system, a monad transformer called RVarT which extends an arbitrary monad with non-backtracking nondeterminism. In particular, the RVar type (an alias for RVar Identity) models pure random variables.

random-source

This package provides the backend for RVarT; arbitrary sources of entropy. Its design is still in major flux.

random-fu

This package provides an end-user interface that defines random variables following several standard distributions as well as some convenient interfaces for sampling them.

Usage

To use the system, you'll typically want import at least two modules: Data.Random for the main interface and a supported entropy source, such as System.Random.MWC from the mwc-random package. You may also want to import one or more of the extra distributions provided in the Data.Random.Distribution heirarchy (uniform and normal are exported by Data.Random automatically). Then, you can define random variables using do notation, sample them using sampleFrom, etc. For example:

import Data.Random
import System.Random.MWC (create)

logNormal :: Double -> Double -> RVar Double
logNormal mu sigmaSq = do
    x <- normal mu sigmaSq
    return (exp x)

main = do
    mwc <- create
    y <- sampleFrom mwc (logNormal 5 1)
    print y

Developers

Ensure that you run the benchmarks before making a PR e.g. stack bench and then run the resulting binary.