pub fn monte_carlo_test<U: UniformGenerator>(
data: &[Vec<f64>],
rvs: impl FnMut(usize, usize, &mut U) -> Vec<f64>,
statistic: impl Fn(&[Vec<f64>]) -> f64,
alternative: Alternative,
n_resamples: usize,
rng: &mut U,
) -> Result<MonteCarloResult, ErrorsJSL>Expand description
A Monte Carlo hypothesis test (SciPy’s monte_carlo_test): the statistic of the observed
samples is compared with its values on n_resamples sets of samples of the same sizes drawn
from the null distribution by rvs(sample index, size, rng). The p-value counts the observed
value among the resamples, (#{T* ≥ T} + 1)/(n + 1), so it is never zero, and two-sided
p-values double the smaller tail.