Safe Haskell | Safe-Infered |
---|
- type CNMonad a = GraphMonad DirectedSG () Distri a
- data CV
- data DN
- class VariableName m where
- mkVariable :: m -> CNMonad CV
- class BayesianVariable v where
- data Distri
- type ContinuousNetwork = SBN Distri
- type ContinuousSample = SBN CVI
- class InstantiationValue i v | i -> v where
- instantiationValue :: i -> v
- toDouble :: i -> Double
- data CVI
- uniform :: VariableName s => s -> DN -> DN -> CNMonad DN
- normal :: VariableName s => s -> DN -> DN -> CNMonad DN
- beta :: VariableName s => s -> DN -> DN -> CNMonad DN
- beta' :: VariableName s => s -> DN -> DN -> CNMonad DN
- exponential :: VariableName s => s -> DN -> CNMonad DN
- execCN :: CNMonad a -> ContinuousNetwork
- runCN :: CNMonad a -> (a, ContinuousNetwork)
- evalCN :: CNMonad a -> a
- runSampling :: (DirectedGraph g, FunctorWithVertex g) => Int -> Int -> Sampler g a -> IO [Sample g a]
- continuousMCMCSampler :: ContinuousNetwork -> [CVI] -> Sampler DirectedSG CVI
- (=:) :: Instantiable d v r => d -> v -> r
- histogram :: Int -> [Double] -> [(Double, Double, Double)]
- samplingHistograms :: (InstantiationValue i v, BayesianVariable i, FunctorWithVertex g, Graph g) => Int -> [Sample g i] -> Sample g [(Double, Double, Double)]
Types
For the graph description
type CNMonad a = GraphMonad DirectedSG () Distri aSource
The Bayesian monad
A continuous variable
An expression which can be a constant, variable or formula.
In case it is a variable, it can be used as a BayesianVariable
or instantiated as an Instantiable
type.
Otherwise you'll get an error
class VariableName m whereSource
This class is used to simplify the network description. Variable names can be optional. In that later case, () must be used instead of a name.
mkVariable :: m -> CNMonad CVSource
class BayesianVariable v whereSource
A Bayesian Variable is a variable part of Bayesian network and so which knows its position : the vertex.
For the sampling
type ContinuousNetwork = SBN DistriSource
type ContinuousSample = SBN CVISource
class InstantiationValue i v | i -> v whereSource
instantiationValue :: i -> vSource
A continuous variable instantiation
Network creation functions
:: VariableName s | |
=> s | Variable name |
-> DN | Min bound |
-> DN | Max bound |
-> CNMonad DN |
Uniform dstribution
:: VariableName s | |
=> s | Variable name |
-> DN | Average |
-> DN | Standard deviation |
-> CNMonad DN |
Normal distribution
exponential :: VariableName s => s -> DN -> CNMonad DNSource
Exponential distribution
execCN :: CNMonad a -> ContinuousNetworkSource
Create a network but only returns the monad value. Mainly used for testing.
runCN :: CNMonad a -> (a, ContinuousNetwork)Source
Create a network using the simple graph implementation The initialized nodes are replaced by the value. Returns the monad values and the built graph.
evalCN :: CNMonad a -> aSource
Create a bayesian network but only returns the monad value. Mainly used for testing.
Sampling functions
:: (DirectedGraph g, FunctorWithVertex g) | |
=> Int | Number of used samples |
-> Int | Burnin samples before the used samples |
-> Sampler g a | Sampler |
-> IO [Sample g a] | List of generated samples |
Sample a bayesian network using a given sampling scheme
:: ContinuousNetwork | Bayesian network |
-> [CVI] | Evidence |
-> Sampler DirectedSG CVI | Sampler |
Gibbs sampling for continuous network
(=:) :: Instantiable d v r => d -> v -> rSource
Create a variable instantiation using values from an enumeration
Result statistics
Compute the histogram of values
:: (InstantiationValue i v, BayesianVariable i, FunctorWithVertex g, Graph g) | |
=> Int | Number of bins |
-> [Sample g i] | Samples |
-> Sample g [(Double, Double, Double)] | Histogram with start bins and bin content |
Generate a graph of sampling histogram for each variable So, for a vertex v we have the posterior values p(v)