Skip to main content

ci_core/
strategy.rs

1use ndarray::{Array1, Array2};
2
3/// The outcome of a conditional independence test.
4#[derive(Debug, Clone, PartialEq)]
5pub enum TestResult {
6    PValue(f64, f64),
7    Statistic(f64, f64, usize),
8    Boolean(bool),
9}
10
11/// Data types that a `CITest` can be performed on.
12#[derive(Debug, Clone, Copy, PartialEq)]
13pub enum CITestDataType {
14    Continuous,
15    Discrete,
16    Mixed,
17}
18
19/// Trait defining the interface for conditional independence tests.
20///
21/// All statistical tests for conditional independence must implement this trait
22/// to be compatible with the registry system.
23pub trait CITest: Send + Sync {
24    /// Runs a conditional independence test on the given data.
25    ///
26    /// # Errors
27    ///
28    /// Returns an error if the test computation fails (e.g., invalid input dimensions or numerical issues).
29    fn run_test(
30        &self,
31        x_values: Array1<f64>,
32        y_values: Array1<f64>,
33        z: Array2<f64>,
34    ) -> anyhow::Result<TestResult>;
35
36    /// Data types that a test supports.
37    fn data_types(&self) -> &'static [CITestDataType];
38}