Class JunctionTreeUpdaterTest

java.lang.Object
edu.cmu.tetrad.bayes.JunctionTreeUpdaterTest

public final class JunctionTreeUpdaterTest extends Object
Test class for verifying the functionality of operations related to junction tree updates in Bayesian networks. This class contains methods for evaluating propagation of evidence, handling interventions, and other utility functions related to Bayesian inference and updates.

Fields: - EPS: Permissible error tolerance for comparing probability distributions.

Methods: - idx(BayesIm im, String name): Retrieves the index of a node in the Bayesian network by its name. - assertDistClose(double[] a, double[] b, double eps): Verifies that two probability distributions are within a specified tolerance. - distDiff(double[] a, double[] b): Computes the maximum absolute difference between two distributions. - evidenceXEquals(BayesIm im, String varName, int value): Creates evidence to constrain a variable to a specific single value (hard evidence). - manipulateXToValue(BayesIm im, Evidence e, String varName, int value): Marks a variable as manipulated and sets its do() distribution to a point mass at a specified value. - assertCptEqualByName(BayesIm src, BayesIm dst, String nodeName, double eps): Compares two conditional probability tables (CPTs) for a node by its name, avoiding dependencies on row order. - buildToyBayesIm(): Constructs a small binary Bayesian network with non-symmetric conditional probability tables (CPTs) for testing purposes. - setBinaryCptOneParent(BayesIm im, int child, int parent, int parentVal, double p0): Configures the conditional probability table (CPT) for a binary child node with one binary parent, based on a specified probability. - testEvidencePropagatesUpAndDown_andUpdatersAgree(): Verifies that evidence propagation occurs correctly both upward and downward in the Bayesian network structure, with consistency across updaters. - testDoInterventionRemovesParents_preservesOtherCpts_andUpdatersAgree(): Checks the behavior of a do() intervention to ensure that incoming edges are removed, non-intervention CPTs are preserved, and agreement exists across inference methods.

  • Constructor Details

    • JunctionTreeUpdaterTest

      public JunctionTreeUpdaterTest()
      Test class for verifying the functionality of the JunctionTreeUpdater component, utilized for probabilistic reasoning and evidence propagation in Bayesian networks. This class contains unit tests and utility methods designed to test the correct behavior of evidence propagation, intervention operations, and agreement between different methods of inference.
  • Method Details

    • testEvidencePropagatesUpAndDown_andUpdatersAgree

      public void testEvidencePropagatesUpAndDown_andUpdatersAgree()
      Structure: X1 -> X2 -> X3 -> X5 \-> X4

      Evidence: X3 = 1 should propagate: - Up: X2 and X1 change - Down: X5 changes - Side child: X4 changes because X2 changes

    • testDoInterventionRemovesParents_preservesOtherCpts_andUpdatersAgree

      public void testDoInterventionRemovesParents_preservesOtherCpts_andUpdatersAgree()
      (3) do(X): incoming edges removed, other CPTs preserved, manipulated CPT set to intervention distribution. (4) Agreement between methods under manipulation too.