hbayes-0.5.2: Bayesian Networks

Bayes.InfluenceDiagram

Contents

Description

Tools to build influence diagrams

Synopsis

# Type

type InfluenceDiagram = DirectedSG EdgeKind IDValue Source

Influence diagram

type DecisionFactor = PrivateCPT Vector DVI Source

class Instantiable d v r | d -> r where Source

Methods

(=:) :: d -> v -> r Source

Create a variable instantiation using values from an enumeration

Instances

 (Bounded b, Enum b) => Instantiable DV b DVI Source Source Source Source (Bounded b, Enum b) => Instantiable (TDV b) b DVI Source

data DEV Source

Decision variable

data UV Source

Utility variable

Instances

 Source

data DV Source

A discrete variable

Instances

 Source Source Source Source Source (Bounded b, Enum b) => Instantiable DV b DVI Source

data TDV s Source

A typed discrete variable

Instances

 Eq (TDV s) Source Ord (TDV s) Source Show (TDV s) Source Source Source (Bounded b, Enum b) => Instantiable (TDV b) b DVI Source

type IDMonad g a = NetworkMonad g EdgeKind IDValue a Source

# Building

t :: t Source

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

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 DEV Source

Create a decision node

Create an utility node

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

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 DEV Source

Define a decision dependence

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

Define a utility dependence

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

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

d :: DEV -> PorD Source

Used to mix decision and chance variables and a same list

p :: ChanceVariable c => c -> PorD Source

Used to mix decision and chance variables and a same list

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)

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

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.

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

Instances

 Source Source Source Source Source (Bounded b, Enum b) => Instantiable DV b DVI Source Source (Bounded b, Enum b) => Instantiable (TDV b) b DVI Source