CITests

group CI-test

Conditional Independence (CI) test

Functions

bool citest(std::size_t x, std::size_t y, const std::vector<std::size_t> &sepset_candidate, const ContingencyTable &ct, const CITestType &ci_test_type)

Conditional–independence test for discrete variables.

The contingency table ct is stored sparsely, i.e. cells with observed count 0 do not appear. pgmpy/Scipy, however, still accounts for such cells if the expected frequency is non‑zero. We therefore generate those cells on‑the‑fly: for each Z‑slice we iterate over the Cartesian product of the actually observed X–states and Y–states and fill in obs = 0 where necessary.

Parameters:
  • x – The first variable

  • y – The second variable

  • sepset_candidate – The candidate separator set

  • ct – The contingency table

  • ci_test_type – The CI test type

Returns:

True if the conditional independence test passes (p_value >= alpha), false otherwise.

template<typename T>
bool is_type(const CITestType &ci_test)

Check if the CI test type is of a specific type.

Template Parameters:

T – A CI test type

Parameters:

ci_test – A CI test type

Returns:

True if the CI test type is of the specific type; otherwise, false

template<typename T>
const T &get_type(const CITestType &ci_test)

Get the CI test type of a specific type.

Template Parameters:

T – A CI test type

Parameters:

ci_test – A CI test type

Returns:

The CI test type of the specific type

inline bool is_d_separated(const PDAG &g, std::size_t x, std::size_t y, const std::vector<std::size_t> &Z)

Check if two variables x and y are d-separated given a PDAG and a set of observed variables Z.

Parameters:
  • g – The PDAG to check.

  • x – The first variable index.

  • y – The second variable index.

  • Z – The set of observed variable indices.

Returns:

True if x and y are d-separated, false otherwise.

struct ChiSquare
#include <citest_type.h>

CItest type for Chi-Square tests.

struct GSquare
#include <citest_type.h>

CItest type for G-Square tests.

struct OracleGraph
#include <citest_type.h>

CItest type for Oracle Graph.