-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Learning Algorithms -- -- Learning Algorithms @package learn @version 0.1.1 -- | 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 --module Numeric.Learn type Prob = Ratio Integer newtype Distro a Distro :: Map a Prob -> Distro a runDistro :: Distro a -> Map a Prob data Result Positive :: Result Negative :: Result -- | Takes a list of elements and generates a uniform Distro over them. uniformPDF :: Ord k => [k] -> Distro k -- | Generates a simulated uniform distro over [0,1] with user supplied -- granularity. uniformPrior :: Integer -> Distro Prob -- | Updates a distro with a new trial that either succeeded or failed. singleCoin :: Distro Prob -> Result -> Distro Prob -- | Updates a distro with many trials, all of which either succeeded or -- failed. coins :: Distro Prob -> Int -> Int -> Distro Prob -- | Convert a Distro to a list of tuples for easier plotting. listify :: Distro k -> [(k, Prob)] instance Eq a => Eq (Distro a) instance Ord a => Ord (Distro a) instance (Ord a, Read a) => Read (Distro a) instance Show a => Show (Distro a)