hbayes-0.4: Inference with Discrete Bayesian Networks

Safe HaskellSafe-Infered

Bayes.InfluenceDiagram

Contents

Description

Tools to build influence diagrams

Synopsis

Type

type InfluenceDiagram = DirectedSG EdgeKind IDValueSource

Influence diagram

type DecisionFactor = PrivateCPT Vector DVISource

class Instantiable d v whereSource

Methods

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

Create a variable instantiation using values from an enumeration

Instances

data DEV Source

Decision variable

data UV Source

Utility variable

Instances

Eq UV 
Initializable UV 

data DV Source

A discrete variable

Instances

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

Instances

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 

Building

t :: aSource

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

(~~)Source

Arguments

:: (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

Solving

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.

Testing

type DVISet = [DVI]Source

data DVI Source

Discrete Variable instantiation. A variable and its value