Package

purescript-probability

Repository
colehaus/purescript-probability
License
BSD-3-Clause
Uploaded by
colehaus
Published on
2018-04-18

Module Math.Probability

Provides monadic interface for computation with discrete random variables. Based on: http://web.engr.oregonstate.edu/~erwig/papers/PFP_JFP06.pdf

Prob

type Prob = P.Prob

prob

prob :: Number -> Maybe P.Prob

runProb

runProb :: P.Prob -> Number

ProbList

type ProbList = P.ProbList

probList

probList :: [P.Prob] -> Maybe P.ProbList

runProbList

runProbList :: P.ProbList -> [P.Prob]

Dist

type Dist = P.Dist

dist

dist :: forall a. [Tuple a P.Prob] -> Maybe (P.Dist a)

zipDist

zipDist :: forall a. [a] -> P.ProbList -> P.Dist a

fromFreqs

fromFreqs :: forall a. [Tuple a Number] -> Maybe (P.Dist a)

choose

choose :: forall a. P.Prob -> a -> a -> P.Dist a

runDist

runDist :: forall a. P.Dist a -> [Tuple a Number]

distProbs

distProbs :: forall a. P.Dist a -> P.ProbList

extract

extract :: forall a. P.Dist a -> [a]

Spread

type Spread a = [a] -> Maybe (P.Dist a)

uniform

uniform :: forall a. Spread a

relative

relative :: forall a. [Number] -> Spread a

reshape

reshape :: forall a. Spread a -> P.Dist a -> Maybe (P.Dist a)

norm

norm :: forall a. (Ord a) => P.Dist a -> P.Dist a

Event

type Event a = a -> Boolean

oneOf

oneOf :: forall a. (Eq a) => [a] -> Event a

just

just :: forall a. (Eq a) => a -> Event a

(??)

(??) :: forall a. Event a -> P.Dist a -> P.Prob

(?=<<)

(?=<<) :: forall a. Event a -> P.Dist a -> Maybe (P.Dist a)

(>>=?)

(>>=?) :: forall a. P.Dist a -> Event a -> Maybe (P.Dist a)

filter

filter :: forall a. Event a -> P.Dist a -> Maybe (P.Dist a)

cond

cond :: forall a. P.Dist Boolean -> P.Dist a -> P.Dist a -> P.Dist a

joinDists

joinDists :: forall a b c. (a -> b -> c) -> P.Dist a -> (a -> P.Dist b) -> P.Dist c

marginalize

marginalize :: forall a b. (Eq b) => (a -> b) -> P.Dist a -> P.Dist b

Iso

data Iso a b
  = Iso (a -> b) (b -> a)

to

to :: forall a b. Iso a b -> a -> b

from

from :: forall a b. Iso a b -> b -> a

expected

expected :: forall a. Iso a Number -> P.Dist a -> a

variance

variance :: forall a. Iso a Number -> P.Dist a -> a

stdDev

stdDev :: forall a. Iso a Number -> P.Dist a -> a

approx

approx :: forall a. (Ord a) => P.Dist a -> P.Dist a -> Boolean

size

size :: forall a. P.Dist a -> Number

map

map :: forall a b. (Ord b) => (a -> b) -> P.Dist a -> P.Dist b

mapMaybe

mapMaybe :: forall a b. (a -> Maybe b) -> P.Dist a -> Maybe (P.Dist b)

Module Math.Probability.Internal

Data declarations which are hidden behind smart constructors in Probability.

Prob

newtype Prob
  = Prob Number

ProbList

newtype ProbList
  = ProbList [Prob]

Dist

newtype Dist a
  = Dist [Tuple a Number]

epsilon

epsilon :: Number

(~~)

(~~) :: Number -> Number -> Boolean

(/~)

(/~) :: Number -> Number -> Boolean

(<~)

(<~) :: Number -> Number -> Boolean

(>~)

(>~) :: Number -> Number -> Boolean

lift

lift :: forall a. ([Tuple a Number] -> [Tuple a Number]) -> Dist a -> Dist a

sumP

sumP :: forall a. [Tuple a Number] -> Number

sortP

sortP :: forall a. [Tuple a Number] -> [Tuple a Number]

sortElem

sortElem :: forall a. (Ord a) => [Tuple a Number] -> [Tuple a Number]

norm'

norm' :: forall a. (Ord a) => [Tuple a Number] -> [Tuple a Number]

isValid

isValid :: forall a. [Tuple a Number] -> Boolean

functorDist

instance functorDist :: Functor Dist

applyDist

instance applyDist :: Apply Dist

applicativeDist

instance applicativeDist :: Applicative Dist

bindDist

instance bindDist :: Bind Dist

monadDist

instance monadDist :: Monad Dist

eqProb

instance eqProb :: Eq Prob

ordProb

instance ordProb :: Ord Prob

showProb

instance showProb :: Show Prob

eqDist

instance eqDist :: (Eq a) => Eq (Dist a)

ordDist

instance ordDist :: (Ord a) => Ord (Dist a)

showDist

instance showDist :: (Show a) => Show (Dist a)

eqProbList

instance eqProbList :: Eq ProbList

ordProbList

instance ordProbList :: Ord ProbList

showProbList

instance showProbList :: Show ProbList