Skip to content

A light-weight library for functionally manipulating probability distributions in Haskell.

Notifications You must be signed in to change notification settings

moteutsch/haskell-prob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Usage

Calculating probability of event:

We calculate the probabilility of getting more than four (4) "heads" out of nine (9) coin-flips. We do this by letting omega be the product space (in mathematical symbols)

{True, False}^9

and then applying pPred to find the probability of a predicate occuring in a distribution.

$ ghci -i Prob.hs

> let omega = crossSeq $ replicate 9 coinflip
> pPred omega ((>4) . length . filter (==True))
>>> 1 % 2

Sampling events:

Here we create a distribution omega and sample a random event from the distribution (in the IO monad).

$ ghci -i Prob.hs

> let numberDistrib = fmap (\x -> x * x `mod` 5) $ uniformOnSample [1..10]
> let omega = uniformOnSample ["Type 1", "Type 2"] `cross` numberDistrib
> event <- randomEvent omega
> putStrLn $ show event
>>> ("Type 2", 4)

About

A light-weight library for functionally manipulating probability distributions in Haskell.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published