/** * Bootstrap estimate of the sampling distribution of a statistic. * * @example * const result = bootstrap(data, (xs) => median(xs), { nResamples: 5000 }) * result.confidenceInterval // [low, high] * * @param {Array} data - The sample. * @param {function(Array): number} [statistic=mean] - Statistic computed on a sample. * @param {Object} [options] * @param {number} [options.nResamples=9999] - Number of bootstrap resamples. * @param {number} [options.confidence=0.95] - Confidence level of the interval. * @param {string} [options.method='BCa'] - 'BCa' (bias-corrected and accelerated, scipy's * default) or 'percentile'. * @returns {BootstrapResult} */ export function bootstrap(data: any[], statistic?: (arg0: any[]) => number, { nResamples, confidence, method }?: { nResamples?: number; confidence?: number; method?: string; }): BootstrapResult; /** * Two-sample permutation test of the null hypothesis that both samples come from the same * distribution. * * @example * permutationTest(control, treatment).pvalue * * @param {number[]} x - First sample. * @param {number[]} y - Second sample. * @param {function(number[], number[]): number} [statistic] - Test statistic; difference of means by default. * @param {Object} [options] * @param {number} [options.nResamples=9999] - Number of random permutations. * @param {string} [options.alternative='two-sided'] - 'two-sided', 'greater' or 'less'. * @returns {PermutationTestResult} */ export function permutationTest(x: number[], y: number[], statistic?: (arg0: number[], arg1: number[]) => number, { nResamples, alternative }?: { nResamples?: number; alternative?: string; }): PermutationTestResult; export type BootstrapResult = { /** * - The statistic on the original data. */ estimate: number; /** * - Standard deviation of the bootstrap distribution. */ standardError: number; /** * - Mean of the bootstrap distribution minus the estimate. */ bias: number; /** * - [lower, upper] bounds. */ confidenceInterval: number[]; /** * - The bootstrap replicates of the statistic. */ distribution: number[]; }; export type PermutationTestResult = { /** * - The observed statistic. */ statistic: number; /** * - The permutation p-value. */ pvalue: number; /** * - Statistic values under random relabelling. */ nullDistribution: number[]; };