fdars_core/inference/mod.rs
1//! Functional two-sample inference tests.
2//!
3//! This module provides fdars' first standalone functional-inference surface:
4//! two-sample functional hypothesis tests built by reusing existing
5//! permutation, Hotelling-T², and bootstrap-band machinery elsewhere in the
6//! crate. It is additive and non-breaking — no existing public signature is
7//! altered by this module.
8//!
9//! # R baselines
10//!
11//! The functions here mirror the table-stakes two-sample tests from the R FDA
12//! ecosystem:
13//!
14//! * [`t_perm_test`] / [`f_perm_test`] — `fda::tperm.fd` / `fda::Fperm.fd`
15//! (permutation two-sample mean tests).
16//! * [`two_sample_mean_test`] — the FPC-basis Hotelling-T² mean-equality test
17//! in the spirit of `fda.usc` mean/covariance equality tests.
18//! * [`mean_scb`] / [`scb_two_sample_test`] — `SCBmeanfd`-style simultaneous
19//! confidence bands for the mean and the mean difference.
20//!
21//! # Conventions
22//!
23//! Permutation tests take an explicit deterministic `seed`
24//! (`StdRng::seed_from_u64(seed)`) and default to `n_perm = 999` at the call
25//! site. All public functions return `Result<_, FdarError>` and validate their
26//! inputs at entry. Result structs derive `Debug, Clone, PartialEq` and are
27//! serde-gated.
28
29mod anova;
30mod dist;
31mod flm;
32mod hotelling;
33mod itp;
34mod permutation;
35mod scb;
36
37pub use anova::oneway_anova_vstat;
38pub use flm::{flm_f_test, flm_gof_test};
39pub use hotelling::two_sample_mean_test;
40pub use itp::{itp_flm, itp_one_pop, itp_two_pop, ItpResult};
41pub use permutation::{f_perm_test, t_perm_test, DEFAULT_N_PERM};
42pub use scb::{mean_scb, scb_two_sample_test};
43
44/// Result of a functional two-sample hypothesis test.
45///
46/// Carries the observed test statistic and the associated p-value. For
47/// permutation-based tests, `n_perm` records the number of permutations used;
48/// for the non-permutation (asymptotic / SCB) paths it is `0`.
49#[derive(Debug, Clone, PartialEq)]
50#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
51#[non_exhaustive]
52pub struct TestResult {
53 /// Observed test statistic.
54 pub statistic: f64,
55 /// P-value for the null hypothesis of equal group means.
56 pub p_value: f64,
57 /// Number of permutations used (0 for non-permutation paths).
58 pub n_perm: usize,
59}