Skip to content

Network ​

Definition

Throughout the manual, with the term network we will refer to the union of Enhanced Bayesian Network, Bayesian Network and Credal Network.

A network is a directed acyclic graph (DAG) whose vertices are nodes and whose edges encode direct probabilistic dependence: an edge parent → child means the child's distribution is conditioned on the parent. Three network types make up the modelling front-end, differing only in the kind of nodes they admit:

TypeNodesPurpose
BayesianNetwork [4]discrete, preciseclassical BN, ready for inference
CredalNetwork (CN) [6]discrete, at least one impreciseCN over interval CPTs, ready for inference
EnhancedBayesianNetwork (eBN) [1]discrete + continuous + functional, precise or imprecisegeneral model that is reduced to one of the above

An eBN is the expressive modelling layer: it may mix discrete, continuous, and functional nodes. Inference is not performed on it directly, it is first reduced (see Reduction & Structural Reliability Problem) to a purely discrete BN or CN, depending on whether any imprecision is present.

A BN and a CN can also be built directly when the model is already discrete.

Building and validating a network ​

Every network is assembled the same way: construct the nodes, group them into a network, wire the edges with add_child!, and finalize with order!.

add_child! records directed edges. Each endpoint may be a single node or a vector, given by name (Symbol) or as node objects, so a whole fan-out can be wired at once, add_child!(net, :W, [:S, :R]). It rejects self-loops, requires every referenced node to exist, checks that a discrete parent appears in each non-functional child's Conditional Probability Table (CPT), and enforces the structural rule that continuous and functional parents may feed only functional children (a continuous quantity cannot condition a plain discrete CPT).

order! sorts the nodes into a topological order and runs the global checks: the graph must be acyclic and connected, no CPT may reference a parent that was never linked, and every discrete CPT must be exhaustive over all parent/own-state combinations.

Bayesian Network ​

A BayesianNetwork is a DAG of discrete and precise nodes, the classical formulation [4]. Its constructor rejects any imprecise node, pointing you to a CN instead, and it requires node names and states to be globally unique. Once ordered, it supports the full inference and sampling machinery (see Inference).

julia
W = DiscreteNode(:W)
W[:W => :sunny]  = 0.5
W[:W => :cloudy] = 0.5

S = DiscreteNode(:S, [:W])
S[:W => :sunny,  :S => :on] = 0.9
S[:W => :sunny,  :S => :off] = 0.1
S[:W => :cloudy, :S => :on] = 0.2
S[:W => :cloudy, :S => :off] = 0.8

bn = BayesianNetwork([W, S])
add_child!(bn, :W, :S)                      # wire parent → child (by name or by node)
bn
BayesianNetwork

Nodes: 2
Edges: 1

Topology:

#   Node            States              Parents
--------------------------------------------------------------------------------
1   W               sunny, cloudy       -
2   S               on, off             W
julia
order!(bn)                                  # topologically sort and validate
bn
BayesianNetwork

Nodes: 2
Edges: 1

Topology:

#   Node            States              Parents
--------------------------------------------------------------------------------
1   W               sunny, cloudy       -
2   S               on, off             W

Credal Network ​

When a discrete CPT carries interval-valued probability entries, the node is imprecise and the network becomes a CredalNetwork [6]. Each local CPT is then a closed convex set of probability measures, a credal set [8], and the network stands for the whole family of BNs that share its graph but differ in the measures drawn from those sets. Imprecision is expressed with probability Intervals.

julia
Wc = DiscreteNode(:Wc)
Wc[:Wc => :sunny] = 0.5
Wc[:Wc => :cloudy] = 0.5
Sc = DiscreteNode(:Sc, [:Wc])
# a single interval entry makes the node — and hence the network — imprecise:
Sc[:Wc => :sunny,  :Sc => :on]  = Interval(0.8, 0.95)
Sc[:Wc => :sunny,  :Sc => :off] = Interval(0.05, 0.2)
Sc[:Wc => :cloudy, :Sc => :on]  = 0.2
Sc[:Wc => :cloudy, :Sc => :off] = 0.8

cn = CredalNetwork([Wc, Sc])
add_child!(cn, :Wc, :Sc)
cn
CredalNetwork

Nodes: 2
Edges: 1
Precise nodes: 1
Credal nodes: 1

Topology:

#   Node            Precision   Parents
--------------------------------------------------------------------------------
1   Wc              Precise     -
2   Sc              Credal      Wc
julia
order!(cn)
cn
CredalNetwork

Nodes: 2
Edges: 1
Precise nodes: 1
Credal nodes: 1

Topology:

#   Node            Precision   Parents
--------------------------------------------------------------------------------
1   Wc              Precise     -
2   Sc              Credal      Wc

Constructing a CN whose nodes all turn out precise emits a warning, a BN is the right structure in that case. The reverse transition happens automatically: after reduction, a credal network whose imprecision has vanished is narrowed back to aBN.

Enhanced Bayesian Network ​

An EnhancedBayesianNetwork is the general modelling front-end: it may hold discrete nodes, continuous nodes, and functional nodes side by side. Continuous and functional nodes carry the physics of the problem (see Nodes), so the eBN cannot be queried directly.

julia
Wf = DiscreteNode(:Wf, [:sunny => [Parameter(1.0, :Wf)], :cloudy => [Parameter(2.0, :Wf)]])
Wf[:Wf => :sunny] = 0.5
Wf[:Wf => :cloudy] = 0.5
X = ContinuousNode(:X, Uniform(-1, 1), ExactDiscretization([-1.0, 0.0, 1.0]))
model = Model(df -> df.X .+ df.Wf, :Y)
F = DiscreteFunctionalNode(:F, [model], df -> df.Y, MonteCarlo(200))

ebn = EnhancedBayesianNetwork([Wf, X, F])
add_child!(ebn, :Wf, :F)
add_child!(ebn, :X, :F)
ebn
EnhancedBayesianNetwork

Nodes: 3
Edges: 2
Discrete nodes: 2
Continuous nodes: 1
Functional nodes: 1

Topology:

Node                Type                    Precision   Parents
--------------------------------------------------------------------------------
Wf                  Discrete                Precise     -
X                   Continuous              Precise     -
F                   DiscreteFunctional                  Wf, X
julia
order!(ebn)
ebn
EnhancedBayesianNetwork

Nodes: 3
Edges: 2
Discrete nodes: 2
Continuous nodes: 1
Functional nodes: 1

Topology:

Node                Type                    Precision   Parents
--------------------------------------------------------------------------------
Wf                  Discrete                Precise     -
X                   Continuous              Precise     -
F                   DiscreteFunctional                  Wf, X

Inspecting structure ​

Once ordered, a network can be queried for its local structure. These accessors take the network and a node name:

  • parents / children: the direct predecessors / successors of a node.

  • discrete_ancestors: the discrete nodes reachable upstream, skipping continuous ones; these define the scenario grid over which a functional node is evaluated.

  • markov_blanket: a node's parents, children, and spouses (co-parents); the minimal set that renders it conditionally independent of the rest of the network.

  • markov_envelope: the groups of continuous nodes linked through shared Markov blankets, together with those blankets; a structural query over the network.

Formally, the Markov blanket of a node Zi is the union of its parents Pa(Zi), its children Ch(Zi), and its spouses Sp(Zi), the other parents of its children:

Bl(Zi)=Pa(Zi)∪Ch(Zi)∪Sp(Zi).
julia
markov_envelope(ebn)
1-element Vector{Vector{Symbol}}:
 [:F, :Wf, :X]

Reduction ​

An eBN is not queried directly, it is transformed into an inference-ready discrete network (BN or CN) by reduce, which discretizes its continuous nodes and evaluates its functional nodes as structural reliability problems, yielding a BN or a CN. Because reduction is the core operation of the library and the route through which imprecision reaches the inference result, it has its own chapter: Reduction & Structural Reliability Problem.