Skip to main content

t_perm_test

Function t_perm_test 

Source
pub fn t_perm_test(
    data_a: &FdMatrix,
    data_b: &FdMatrix,
    argvals: &[f64],
    n_perm: usize,
    seed: u64,
) -> Result<TestResult, FdarError>
Expand description

Functional two-sample permutation t-test (fda::tperm.fd).

Tests the null hypothesis that data_a and data_b are drawn from populations with the same mean curve. The test statistic is the integrated L2 distance between the two sample-mean curves, sqrt( ∫ (mean_a - mean_b)^2 dt ), integrated with Simpson’s weights over argvals. The permutation null pools all n_a + n_b curves, relabels group membership via a Fisher–Yates shuffle, and recomputes the statistic; the p-value is (#{perm >= observed} + 1) / (n_perm + 1).

§Arguments

  • data_a - First sample (n_a x m).
  • data_b - Second sample (n_b x m).
  • argvals - Evaluation points (length m).
  • n_perm - Number of permutations (typical default: DEFAULT_N_PERM = 999).
  • seed - Deterministic RNG seed (StdRng::seed_from_u64(seed)).

§Errors

Returns FdarError::InvalidDimension if the two samples have unequal or zero column counts, if argvals.len() does not match the column count, or if either sample has fewer than 2 rows. Returns FdarError::InvalidParameter if n_perm == 0.