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 permutation;
34mod scb;
35
36pub use anova::oneway_anova_vstat;
37pub use flm::{flm_f_test, flm_gof_test};
38pub use hotelling::two_sample_mean_test;
39pub use permutation::{f_perm_test, t_perm_test, DEFAULT_N_PERM};
40pub use scb::{mean_scb, scb_two_sample_test};
41
42/// Result of a functional two-sample hypothesis test.
43///
44/// Carries the observed test statistic and the associated p-value. For
45/// permutation-based tests, `n_perm` records the number of permutations used;
46/// for the non-permutation (asymptotic / SCB) paths it is `0`.
47#[derive(Debug, Clone, PartialEq)]
48#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
49#[non_exhaustive]
50pub struct TestResult {
51 /// Observed test statistic.
52 pub statistic: f64,
53 /// P-value for the null hypothesis of equal group means.
54 pub p_value: f64,
55 /// Number of permutations used (0 for non-permutation paths).
56 pub n_perm: usize,
57}