learn-0.1.1: Learning Algorithms

Safe HaskellSafe-Inferred



This library provides tools for doing single parameter Bayesian inference.

Example ghci use:

 # Generate a discrete simulation of the uniform prior for the bias
 # of a single coin on [0,1] using a grid of 100 points.
 let prior = uniformPrior 100
 # Update the prior as if we flipped the coin 100 times and got 25 heads.
 let posterior = coins prior 25 75
 # Optionally, import Graphics.Gnuplot.Simple and convert posterior 
 # to a list of tuples for plotting using listify
 :m + Graphics.Gnuplot.Simple
 plotList [] (listify posterior)
 # As you'd expect, nearly all of the probability mass is concentrated
 # between a bias of 0.2 and 0.3



newtype Distro a Source




runDistro :: Map a Prob


Eq a => Eq (Distro a) 
Ord a => Ord (Distro a) 
(Ord a, Read a) => Read (Distro a) 
Show a => Show (Distro a) 

data Result Source



uniformPDF :: Ord k => [k] -> Distro kSource

Takes a list of elements and generates a uniform Distro over them.

uniformPrior :: Integer -> Distro ProbSource

Generates a simulated uniform distro over [0,1] with user supplied granularity.

singleCoin :: Distro Prob -> Result -> Distro ProbSource

Updates a distro with a new trial that either succeeded or failed.

coins :: Distro Prob -> Int -> Int -> Distro ProbSource

Updates a distro with many trials, all of which either succeeded or failed.

listify :: Distro k -> [(k, Prob)]Source

Convert a Distro to a list of tuples for easier plotting.