Inference : Variable Elimination

Exact Inference in Continuous Linear Gaussian)

Exact inference in the Continuous Linear Gaussian (CLG) model is performed using the Variable Elimination algorithm. The algorithm is implemented in the Inference class. Canonical form transformations are used to perform exact inference in the Continuous Linear Gaussian (CLG) model. A junction tree generator is employed to determine the variable elimination order for the sum-product algorithm.

The inference begins with construction of canonical forms from the CLG parameters. These canonical forms are then subjected to the sum-product variable elimination algorithm to compute posterior densities.

The Inference class allows for the handling of evidence - observation data that can influence the probabilities in the model. These are integrated into the inference calculations.

The class provides functionality to update evidence with new observations, check if evidence exists for a particular variable, and erase one or all pieces of evidence from the model.

The core functionality of the Inference class is to calculate the posterior density of specified variables given current evidence in the CLG model. The posterior density is returned as a canonical form.

class pyAgrum.clg.CLGVariableElimination(clg)
canonicalPosterior(variables, normalized=True)

Returns the posterior density as a canonical form.

Parameters:
  • variables (list) – The list of target variable names.

  • normalized (bool, optional) – Optional parameter to normalize the returned canonical form.

Returns:

The posterior canonical form.

Return type:

CanonicalForm

eraseAllEvidence()

Remove all the evidences.

Parameters:

variable (str) – The variable name.

eraseEvidence(variable)

Remove the evidence corresponding to the variable name.

Parameters:

variable (str) – The variable name.

hasEvidence(variable)

Check if a variable has an evidence.

Parameters:

variable (str) – The variable name.

Returns:

True if the variable has an evidence, False otherwise.

Return type:

bool

nbrEvidence()

Returns the number of evidence.

Returns:

The number of evidence.

Return type:

int

posterior(variable)

Returns the posterior density as a Gaussian variable.

Parameters:

variable (str) – The target variable name.

Returns:

The posterior Gaussian variable.

Return type:

GaussianVariable

updateEvidence(evidence)

Update evidences.

Parameters:

evidence (dict) – A dictionary of evidence.