traq
Safe HaskellSafe-Inferred
LanguageHaskell2010

Traq.Data.Probability.Tree

Description

Probabilistic computation monad.

Synopsis

Tree of outcomes representation of a probability distribution.

data Distr probT a #

A tree representation of a probability distributions. E.g. Distr Double a for real-valued probabilities. Distr () a for non-deterministic value.

Constructors

Leaf a

A deterministic value (probability 1)

Branch [(probT, Distr probT a)]

A probabilistic choice with at least two outcomes

Instances

Instances details
Alternative Tree # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

empty :: Tree a #

(<|>) :: Tree a -> Tree a -> Tree a #

some :: Tree a -> Tree [a] #

many :: Tree a -> Tree [a] #

MonadPlus Tree # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

mzero :: Tree a #

mplus :: Tree a -> Tree a -> Tree a #

ProbType probT => MonadExp probT (Distr probT) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

expectationA :: (Applicative f, RVType probT r) => (a -> f r) -> Distr probT a -> f r #

ProbType probT => MonadProb probT (Distr probT) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

choose :: ProbType probT => [(probT, Distr probT a)] -> Distr probT a #

MonadFail (Distr probT) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

fail :: String -> Distr probT a #

Foldable (Distr probT) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

fold :: Monoid m => Distr probT m -> m #

foldMap :: Monoid m => (a -> m) -> Distr probT a -> m #

foldMap' :: Monoid m => (a -> m) -> Distr probT a -> m #

foldr :: (a -> b -> b) -> b -> Distr probT a -> b #

foldr' :: (a -> b -> b) -> b -> Distr probT a -> b #

foldl :: (b -> a -> b) -> b -> Distr probT a -> b #

foldl' :: (b -> a -> b) -> b -> Distr probT a -> b #

foldr1 :: (a -> a -> a) -> Distr probT a -> a #

foldl1 :: (a -> a -> a) -> Distr probT a -> a #

toList :: Distr probT a -> [a] #

null :: Distr probT a -> Bool #

length :: Distr probT a -> Int #

elem :: Eq a => a -> Distr probT a -> Bool #

maximum :: Ord a => Distr probT a -> a #

minimum :: Ord a => Distr probT a -> a #

sum :: Num a => Distr probT a -> a #

product :: Num a => Distr probT a -> a #

Traversable (Distr probT) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

traverse :: Applicative f => (a -> f b) -> Distr probT a -> f (Distr probT b) #

sequenceA :: Applicative f => Distr probT (f a) -> f (Distr probT a) #

mapM :: Monad m => (a -> m b) -> Distr probT a -> m (Distr probT b) #

sequence :: Monad m => Distr probT (m a) -> m (Distr probT a) #

Applicative (Distr probT) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

pure :: a -> Distr probT a #

(<*>) :: Distr probT (a -> b) -> Distr probT a -> Distr probT b #

liftA2 :: (a -> b -> c) -> Distr probT a -> Distr probT b -> Distr probT c #

(*>) :: Distr probT a -> Distr probT b -> Distr probT b #

(<*) :: Distr probT a -> Distr probT b -> Distr probT a #

Functor (Distr probT) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

fmap :: (a -> b) -> Distr probT a -> Distr probT b #

(<$) :: a -> Distr probT b -> Distr probT a #

Monad (Distr probT) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

(>>=) :: Distr probT a -> (a -> Distr probT b) -> Distr probT b #

(>>) :: Distr probT a -> Distr probT b -> Distr probT b #

return :: a -> Distr probT a #

(Read a, Read probT) => Read (Distr probT a) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

readsPrec :: Int -> ReadS (Distr probT a) #

readList :: ReadS [Distr probT a] #

readPrec :: ReadPrec (Distr probT a) #

readListPrec :: ReadPrec [Distr probT a] #

(Show a, Show probT) => Show (Distr probT a) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

showsPrec :: Int -> Distr probT a -> ShowS #

show :: Distr probT a -> String #

showList :: [Distr probT a] -> ShowS #

(Eq a, Eq probT) => Eq (Distr probT a) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

(==) :: Distr probT a -> Distr probT a -> Bool #

(/=) :: Distr probT a -> Distr probT a -> Bool #

(Ord a, Ord probT) => Ord (Distr probT a) # 
Instance details

Defined in Traq.Data.Probability.Tree

Methods

compare :: Distr probT a -> Distr probT a -> Ordering #

(<) :: Distr probT a -> Distr probT a -> Bool #

(<=) :: Distr probT a -> Distr probT a -> Bool #

(>) :: Distr probT a -> Distr probT a -> Bool #

(>=) :: Distr probT a -> Distr probT a -> Bool #

max :: Distr probT a -> Distr probT a -> Distr probT a #

min :: Distr probT a -> Distr probT a -> Distr probT a #

flattenAndCompress :: (Num probT, Ord a) => Distr probT a -> Distr probT a #

Flatten a probability tree to one level, and merge equal outcomes.

Non-deterministic monad

type Tree = Distr () #