laop-0.1.1.0: Matrix programming library

Safe HaskellNone
LanguageHaskell2010

LAoP.Dist.Internal

Synopsis

Documentation

newtype Dist a Source #

Type synonym for column vector matrices. This represents a probability distribution.

Constructors

D (Matrix Prob () a) 
Instances
Eq (Dist a) Source # 
Instance details

Defined in LAoP.Dist.Internal

Methods

(==) :: Dist a -> Dist a -> Bool #

(/=) :: Dist a -> Dist a -> Bool #

Num (Dist a) Source # 
Instance details

Defined in LAoP.Dist.Internal

Methods

(+) :: Dist a -> Dist a -> Dist a #

(-) :: Dist a -> Dist a -> Dist a #

(*) :: Dist a -> Dist a -> Dist a #

negate :: Dist a -> Dist a #

abs :: Dist a -> Dist a #

signum :: Dist a -> Dist a #

fromInteger :: Integer -> Dist a #

Ord (Dist a) Source # 
Instance details

Defined in LAoP.Dist.Internal

Methods

compare :: Dist a -> Dist a -> Ordering #

(<) :: Dist a -> Dist a -> Bool #

(<=) :: Dist a -> Dist a -> Bool #

(>) :: Dist a -> Dist a -> Bool #

(>=) :: Dist a -> Dist a -> Bool #

max :: Dist a -> Dist a -> Dist a #

min :: Dist a -> Dist a -> Dist a #

Show (Dist a) Source # 
Instance details

Defined in LAoP.Dist.Internal

Methods

showsPrec :: Int -> Dist a -> ShowS #

show :: Dist a -> String #

showList :: [Dist a] -> ShowS #

NFData (Dist a) Source # 
Instance details

Defined in LAoP.Dist.Internal

Methods

rnf :: Dist a -> () #

type Prob = Double Source #

Type synonym for probability value

type Countable a = KnownNat (Count a) Source #

Constraint type synonyms to keep the type signatures less convoluted

type FLN a b = FL (Normalize a) (Normalize b) Source #

type Liftable a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num Prob, Ord Prob) Source #

fmapD :: (Liftable a b, CountableDimsN a b, FLN b a) => (a -> b) -> Dist a -> Dist b Source #

Functor instance

unitD :: Dist () Source #

Applicative/Monoidal instance unit function

multD :: (CountableDimsN a b, CountableN (a, b), FLN (a, b) a, FLN (a, b) b, TrivialP a b) => Dist a -> Dist b -> Dist (a, b) Source #

Applicative/Monoidal instance mult function

selectD :: (FLN b b, CountableN b) => Dist (Either a b) -> Matrix Prob a b -> Dist b Source #

Selective instance function

branchD :: (Num e, CountableDimsN a b, CountableDimsN c (Either b c), FLN c b, FLN a b, FLN a a, FLN b b, FLN c c, FLN b a, FLN b c, FLN (Either b c) b, FLN (Either b c) c) => Dist (Either a b) -> Matrix Prob a c -> Matrix Prob b c -> Dist c Source #

Chooses which of the two given effectful functions to apply to a given argument;

ifD :: (CountableDimsN a (Either () a), FLN a a, FLN a (), FLN () a, FLN (Either () a) a) => Dist Bool -> Dist a -> Dist a -> Dist a Source #

Branch on a Boolean value, skipping unnecessary computations.

returnD :: forall a. (Enum a, FLN () a, Countable a) => a -> Dist a Source #

Monad instance return function

bindD :: Dist a -> Matrix Prob a b -> Dist b Source #

Monad instance '(>>=)' function

(??) :: (Enum a, Countable a, FLN () a) => (a -> Bool) -> Dist a -> Prob Source #

Extract probabilities given an Event.

choose :: FLN () a => Prob -> Dist a Source #

Constructs a Bernoulli distribution

shape :: FLN () a => (Prob -> Prob) -> [a] -> Dist a Source #

Creates a distribution given a shape function

linear :: FLN () a => [a] -> Dist a Source #

Constructs a Linear distribution

uniform :: FLN () a => [a] -> Dist a Source #

Constructs an Uniform distribution

negExp :: FLN () a => [a] -> Dist a Source #

Constructs an Negative Exponential distribution

normal :: FLN () a => [a] -> Dist a Source #

Constructs an Normal distribution

toValues :: forall a. (Enum a, Countable a, FLN () a) => Dist a -> [(a, Prob)] Source #

Transforms a Dist into a list of pairs.

prettyDist :: forall a. (Show a, Enum a, Countable a, FLN () a) => Dist a -> String Source #

Pretty a distribution

prettyPrintDist :: forall a. (Show a, Enum a, Countable a, FLN () a) => Dist a -> IO () Source #

Pretty Print a distribution