hbayes-0.4.1: Inference with Discrete Bayesian Networks

Bayes.BayesianNetwork

Description

Module for building Bayesian Networks

Synopsis

# Bayesian Monad used to ease creation of Bayesian Networks

runBN :: BNMonad DirectedSG f a -> (a, SBN f)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.

evalBN :: BNMonad DirectedSG f a -> aSource

Create a bayesian network but only returns the monad value. Mainly used for testing.

execBN :: BNMonad DirectedSG f a -> SBN fSource

Create a network but only returns the monad value. Mainly used for testing.

class Distribution d whereSource

A distribution which can be used to create a factor

Methods

createFactor :: Factor f => [DV] -> d -> Maybe fSource

Create a factor from variables and a distributions for those variables

Instances

 Real a => Distribution [a]

## Variable creation

Arguments

 :: (Enum a, Bounded a, NamedGraph g) => String Variable name -> a Variable bounds -> NetworkMonad g e f (TDV a)

Define a Bayesian variable (name and bounds)

Arguments

 :: (Enum a, Bounded a, NamedGraph g) => a Variable bounds -> NetworkMonad g e f (TDV a)

Create a new unamed variable

Arguments

 :: NamedGraph g => String Variable name -> Int Variable size -> NetworkMonad g e f DV

Define a Bayesian variable (name and bounds)

tdv :: DV -> TDV sSource

Typed discrete variable

t :: aSource

Synonym for undefined because it is clearer to use t to set the Enum bounds of a variable

## Creation of conditional probability tables

cpt :: (DirectedGraph g, BayesianDiscreteVariable v, BayesianDiscreteVariable vb) => v -> [vb] -> BNMonad g f vSource

Define a conditional probability between different variables Variables are ordered like FFF FFT FTF FTT TFF TFT TTF TTT and same for other enumeration keeping enumeration order Note that the reverse is important. We add the parents in such a way that `ingoing` will give a list of parents in the right order. This order must correspond to the order of values in the initialization.

proba :: (DirectedGraph g, BayesianDiscreteVariable v) => v -> BNMonad g f vSource

Define proba for a variable Values are ordered like FFF FFT FTF FTT TFF TFT TTF TTT and same for other enumeration keeping enumeration order

Arguments

 :: (DirectedGraph g, Factor f, Distribution d, BayesianDiscreteVariable v) => BNMonad g f v Discrete variable in the graph -> d List of values -> BNMonad g f ()

Initialize the values of a factor

Arguments

 :: (NamedGraph g, DirectedGraph g, Factor f) => TDV Bool Variable on which we want to define Soft evidence -> BNMonad g f (TDV Bool) Return a soft evidence node (for the factor encoding the soft evidence values) and an hard evidence node to activate the soft evidence observation

Create an auxiliairy node to force soft evidence

Arguments

 :: Factor f => TDV s Soft evidence node -> TDV s Node on which the soft evidence is imposed -> Double Soft evidence (probability of right detection) -> Maybe f

Soft evidence factor

## Creation of truth tables

logical :: (Factor f, DirectedGraph g) => TDV Bool -> LE -> BNMonad g f ()Source

(.==.) :: Testable d v => d -> v -> LESource

Create a variable instantiation using values from an enumeration

(.!.) :: LE -> LESource

(.|.) :: LE -> LE -> LESource

(.&.) :: LE -> LE -> LESource

## Noisy OR

Arguments

 :: (DirectedGraph g, Factor f, NamedGraph g) => [(TDV Bool, Double)] Variables and probability of no influence -> BNMonad g f (TDV Bool)

Noisy OR. The Noisy-OR with leak can be implemented by using the standard Noisy-OR and a leak variable.