The probable package

[Tags: bsd3, library]

Easy and reasonably efficient probabilistic programming and random generation

This library gives a common language to speak about probability distributions and random generation, by wrapping both, when necessary, in a RandT monad defined in Math.Probable.Random. This module also provides a lot of useful little combinators for easily describing how random values for your types should be generated.

In Math.Probable.Distribution, you'll find functions for generating random values that follow any distribution supported by mwc-random.

In Math.Probable.Distribution.Finite, you'll find an adaptation of Eric Kidd's work on probability monads (from here).

You may want to check the examples bundled with this package, viewable online at https://github.com/alpmestan/probable/tree/master/examples. One of these examples is simple enough to be worth reproducing here.

 module Main where

 import Control.Applicative
 import Control.Monad
 import Math.Probable

 import qualified Data.Vector.Unboxed as VU

 data Person = Person Int    -- ^ age
                      Double -- ^ weight (kgs)
                      Double -- ^ salary (e.g euros)
     deriving (Eq, Show)

 person :: RandT IO Person
 person =
     Person <$> uniformIn (1, 100)
            <*> uniformIn (2, 130)
            <*> uniformIn (500, 10000)

 randomPersons :: Int -> IO [Person]
 randomPersons n = mwc $ listOf n person

 randomDoubles :: Int -> IO (VU.Vector Double)
 randomDoubles n = mwc $ vectorOf n double

 main :: IO ()
 main = do
     randomPersons 10 >>= mapM_ print
     randomDoubles 10 >>= VU.mapM_ print

Please report any feature request or problem, either by email or through github's issues/feature requests.


Properties

Version0.1.0.0
Dependenciesbase (>=4.5 && <4.8), mtl, mwc-random (>=0.10), primitive, statistics (>=0.10), transformers (>=0.3), vector (>=0.10)
LicenseBSD3
Copyright2014 Alp Mestanogullari
AuthorAlp Mestanogullari
Maintaineralpmestan@gmail.com
CategoryMath, Statistics
Home pagehttp://github.com/alpmestan/probable
Bug trackerhttp://github.com/alpmestan/probable/issues
Source repositoryhead: git clone https://github.com/alpmestan/probable.git
UploadedTue May 27 17:02:37 UTC 2014 by AlpMestanogullari
DistributionsNixOS:0.1.0.0
Downloads158 total (9 in last 30 days)
StatusDocs available [build log]
Successful builds reported [all 1 reports]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees