hbayes-0.4: Inference with Discrete Bayesian Networks

Safe HaskellSafe-Infered




Tools to build influence diagrams



type InfluenceDiagram = DirectedSG EdgeKind IDValueSource

Influence diagram

type DecisionFactor = PrivateCPT Vector DVISource

class Instantiable d v whereSource


(=:) :: d -> v -> DVISource

Create a variable instantiation using values from an enumeration


data DEV Source

Decision variable

data UV Source

Utility variable


Eq UV 
Initializable UV 

data DV Source

A discrete variable


Eq DV 
Ord DV 
Show DV 
Binary DV 
BayesianDiscreteVariable DV 
LabeledVertex DV 
Initializable DV 
ChanceVariable DV 
(Bounded b, Enum b) => Instantiable DV b 
IsCluster [DV] 

data TDV s Source

A typed discrete variable


Eq (TDV s) 
Ord (TDV s) 
Show (TDV s) 
BayesianDiscreteVariable (TDV s) 
Initializable (TDV s) 
ChanceVariable (TDV s) 
(Bounded b, Enum b) => Instantiable (TDV b) b 


t :: aSource

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



:: (Initializable v, DirectedGraph g, Distribution d) 
=> IDMonad g v

Discrete variable in the graph

-> d

List of values

-> IDMonad g () 

chance :: (Bounded a, Enum a, NamedGraph g) => String -> a -> IDMonad g (TDV a)Source

Create a chance node

decisionNode :: (Bounded a, Enum a, NamedGraph g) => String -> a -> IDMonad g DEVSource

Create a decision node

utilityNode :: NamedGraph g => String -> IDMonad g UVSource

Create an utility node

proba :: (ChanceVariable c, DirectedGraph g) => c -> IDMonad g cSource

Define that a chance node is a probability (not conditional) Values are ordered like FFF FFT FTF FTT TFF TFT TTF TTT and same for other enumeration keeping enumeration order

decision :: (DirectedGraph g, BayesianDiscreteVariable dv) => DEV -> [dv] -> IDMonad g DEVSource

Define a decision dependence

utility :: (DirectedGraph g, BayesianDiscreteVariable dv) => UV -> [dv] -> IDMonad g UVSource

Define a utility dependence

cpt :: (DirectedGraph g, BayesianDiscreteVariable vb, ChanceVariable c) => c -> [vb] -> IDMonad g cSource

Define that a chance node is a conditional probability and define the parent variables

d :: DEV -> PorDSource

Used to mix decision and chance variables and a same list

p :: ChanceVariable c => c -> PorDSource

Used to mix decision and chance variables and a same list

noDependencies :: [DV]Source

Used to define a root decision which is not dependent on any past node


decisionsOrder :: InfluenceDiagram -> [ChancesOrDecision]Source

List of decision vertices in reverse temporal order (corresponding to elimination order)

solveInfluenceDiagram :: InfluenceDiagram -> [DecisionFactor]Source

Solve an influence diagram. A DecisionFactor is generated for each decision variable. A decision factor is containing a variable instantiation instead of a double. This instantiation is giving the decision to take for each value of the parents.

runID :: IDMonad DirectedSG a -> (a, InfluenceDiagram)Source

Run an influence monad

policyNetwork :: [DecisionFactor] -> InfluenceDiagram -> SBN CPTSource

Create a policy network from an influence diagram and its solution. A policy network is a Bayesian network where the decision nodes have been replaced with probability nodes where the probability is 1 when the configuration is corresponding to the decision and 0 otherwise.

decisionToInstantiation :: DecisionFactor -> [DVISet]Source

Convert a decision policy to a set of possible instantiations It is the only way to access to the content of a decision factor.


type DVISet = [DVI]Source

data DVI Source

Discrete Variable instantiation. A variable and its value