probability-0.2.5: Probabilistic Functional Programming

Safe HaskellSafe-Inferred
LanguageHaskell98

Numeric.Probability.Transition

Contents

Description

Deterministic and probabilistic generators

Synopsis

Transitions

type Change a = a -> a Source

deterministic generator

type T prob a = a -> T prob a Source

probabilistic generator

id :: Num prob => T prob a Source

map :: (Num prob, Ord a) => Change a -> T prob a -> T prob a Source

map maps a change function to the result of a transformation (map is somehow a lifted form of map) The restricted type of f results from the fact that the argument to t cannot be changed to b in the result T type.

unfold :: (Num prob, Ord a) => T prob (T prob a) -> T prob a Source

unfold a distribution of transitions into one transition

NOTE: The argument transitions must be independent

compose :: (Num prob, Ord a) => [T prob a] -> T prob a Source

Composition of transitions similar to compose but with intermediate duplicate elimination.

untilLeft :: (Num prob, Ord a, Ord b) => (a -> T prob (Either b a)) -> T prob a -> T prob b Source

fix :: (Num prob, Ord a, Ord b) => ((a -> EitherT a (T prob) b) -> a -> EitherT a (T prob) b) -> T prob a -> T prob b Source

In fix $ go a -> do ...; go xy any action after a go is ignored.

Spreading changes into transitions

type SpreadC prob a = [Change a] -> T prob a Source

functions to convert a list of changes into a transition

apply :: Num prob => Change a -> T prob a Source

maybe :: Num prob => prob -> Change a -> T prob a Source

lift :: Spread prob a -> SpreadC prob a Source

uniform :: Fractional prob => SpreadC prob a Source

linear :: Fractional prob => SpreadC prob a Source

normal :: Floating prob => SpreadC prob a Source

enum :: RealFloat prob => [Int] -> SpreadC prob a Source

relative :: RealFloat prob => [prob] -> SpreadC prob a Source

Spreading transitions into transitions

type SpreadT prob a = [T prob a] -> T prob a Source

functions to convert a list of transitions into a transition

liftT :: (Num prob, Ord a) => Spread prob (T prob a) -> SpreadT prob a Source

uniformT :: (Fractional prob, Ord a) => SpreadT prob a Source

linearT :: (Fractional prob, Ord a) => SpreadT prob a Source

normalT :: (Floating prob, Ord a) => SpreadT prob a Source

enumT :: (RealFloat prob, Ord a) => [Int] -> SpreadT prob a Source

relativeT :: (RealFloat prob, Ord a) => [prob] -> SpreadT prob a Source