probable: Easy and reasonably efficient probabilistic programming and random generation
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.
[Skip to Readme]
Modules
[Index]
Downloads
- probable-0.1.3.tar.gz [browse] (Cabal source package)
- Package description (revised from the package)
Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
Versions [RSS] | 0.1.0.0, 0.1.1, 0.1.2, 0.1.3 |
---|---|
Dependencies | base (>=4.8 && <5), mtl (>=2.2 && <2.3), mwc-random (>=0.10 && <0.15), primitive (>=0.6 && <0.7), statistics (>=0.14 && <0.15), transformers (>=0.3 && <0.6), vector (>=0.10 && <0.13) [details] |
Tested with | ghc ==8.0.2, ghc ==8.2.2 |
License | BSD-3-Clause |
Copyright | 2014-2016 Alp Mestanogullari |
Author | Alp Mestanogullari |
Maintainer | alpmestan@gmail.com |
Revised | Revision 3 made by AlpMestanogullari at 2019-03-03T08:11:17Z |
Category | Math, Statistics |
Home page | http://github.com/alpmestan/probable |
Bug tracker | http://github.com/alpmestan/probable/issues |
Source repo | head: git clone https://github.com/alpmestan/probable.git |
Uploaded | by AlpMestanogullari at 2018-02-11T11:45:40Z |
Distributions | |
Reverse Dependencies | 2 direct, 0 indirect [details] |
Downloads | 3337 total (1 in the last 30 days) |
Rating | 2.0 (votes: 1) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Last success reported on 2018-02-11 [all 1 reports] |