GitHub
deepbox/stats

Tests, Confidence & Power

Hypothesis tests, multiple-comparison corrections, and statistical power analysis.
Inference
type MultipleComparisonResult
export interface MultipleComparisonResult { … }
Result of a multiple comparison correction.
type PowerAnalysisResult
export interface PowerAnalysisResult { … }
Result of a power analysis.
type TTestPowerOptions
export interface TTestPowerOptions { … }
Statistical power analysis.
type ContingencyResult
export type ContingencyResult = { statistic: number; pvalue: number; dof: number; expected: number[][]; };
Result of a contingency table analysis (chi-square test).
type TestResult
export type TestResult = { statistic: number; pvalue: number; };
Result of a statistical hypothesis test.
type TwoWayAnovaResult
export type TwoWayAnovaResult = { factorA: TestResult; factorB: TestResult; interaction: TestResult; };
Result of two-way ANOVA test.
type chi2Contingency
export declare const chi2Contingency: typeof chi2_contingency;
chi2Contingency is a public const in deepbox/stats.
type fisherExact
export declare const fisherExact: typeof fisher_exact;
fisherExact is a public const in deepbox/stats.
type fOneway
export declare const fOneway: typeof f_oneway;
fOneway is a public const in deepbox/stats.
type ks2samp
export declare const ks2samp: typeof ks_2samp;
ks2samp is a public const in deepbox/stats.
type ttestInd
export declare const ttestInd: typeof ttest_ind;
ttestInd is a public const in deepbox/stats.
type ttestRel
export declare const ttestRel: typeof ttest_rel;
ttestRel is a public const in deepbox/stats.
benjaminiHochberg
export declare function benjaminiHochberg(pvalues: readonly number[], alpha?: number): MultipleComparisonResult;

Benjamini-Hochberg (BH) procedure for controlling the false discovery rate (FDR).

bonferroni
export declare function bonferroni(pvalues: readonly number[], alpha?: number): MultipleComparisonResult;

Bonferroni correction for multiple comparisons.

holm
export declare function holm(pvalues: readonly number[], alpha?: number): MultipleComparisonResult;

Holm-Bonferroni step-down correction for multiple comparisons.

sidak
export declare function sidak(pvalues: readonly number[], alpha?: number): MultipleComparisonResult;

Šidák correction for multiple comparisons.

tTestPower
export declare function tTestPower(options: TTestPowerOptions): PowerAnalysisResult;

Power analysis for independent two-sample t-test.

anderson
export declare function anderson(x: Tensor): { statistic: number; critical_values: number[]; significance_level: number[]; };

Anderson-Darling test for normality.

bartlett
export declare function bartlett(...samples: Tensor[]): TestResult;

Bartlett's test for equality of variances.

chi2_contingency
export declare function chi2_contingency(observed: readonly (readonly number[])[]): ContingencyResult;

Chi-squared test of independence for a contingency table.

chisquare
export declare function chisquare(f_obs: Tensor, f_exp?: Tensor): TestResult;

Chi-square goodness of fit test.

f_oneway
export declare function f_oneway(...samples: Tensor[]): TestResult;

One-way ANOVA.

f_twoway
export declare function f_twoway(data: number[][][]): TwoWayAnovaResult;

Two-way ANOVA for balanced designs.

fisher_exact
export declare function fisher_exact(table: readonly [readonly [number, number], readonly [number, number]], alternative?: "two-sided" | "less" | "greater"): { oddsRatio: number; pvalue: number; };

Fisher's exact test for a 2×2 contingency table.

fligner
export declare function fligner(groups: readonly Tensor[]): TestResult;

Fligner-Killeen test for equality of variances.

friedmanchisquare
export declare function friedmanchisquare(...samples: Tensor[]): TestResult;

Friedman test (non-parametric repeated measures ANOVA).

kruskal
export declare function kruskal(...samples: Tensor[]): TestResult;

Kruskal-Wallis H-test (non-parametric version of ANOVA).

ks_2samp
export declare function ks_2samp(x: Tensor, y: Tensor): TestResult;

Two-sample Kolmogorov-Smirnov test.

kstest
export declare function kstest(data: Tensor, cdf: string | ((x: number) => number)): TestResult;

Kolmogorov-Smirnov test for goodness of fit.

levene
export declare function levene(center: "mean" | "median" | "trimmed", ...samples: Tensor[]): TestResult;

Levene's test for equality of variances.

lilliefors
export declare function lilliefors(x: Tensor): TestResult;

Lilliefors test for normality.

mannwhitneyu
export declare function mannwhitneyu(x: Tensor, y: Tensor): TestResult;

Mann-Whitney U test (non-parametric).

median_test
export declare function median_test(...samples: Tensor[]): TestResult;

Mood's median test.

normaltest
export declare function normaltest(a: Tensor): TestResult;

Test for normality.

runs_test
export declare function runs_test(x: Tensor): TestResult;

Wald-Wolfowitz runs test for randomness.

shapiro
export declare function shapiro(x: Tensor): TestResult;

Shapiro-Wilk test for normality.

ttest_1samp
export declare function ttest_1samp(a: Tensor, popmean: number): TestResult;

One-sample t-test.

ttest_ind
export declare function ttest_ind(a: Tensor, b: Tensor, equalVar?: boolean): TestResult;

Independent two-sample t-test.

ttest_rel
export declare function ttest_rel(a: Tensor, b: Tensor): TestResult;

Paired-sample t-test.

wilcoxon
export declare function wilcoxon(x: Tensor, y?: Tensor): TestResult;

Wilcoxon signed-rank test (non-parametric paired test).

stats-tests.ts
import {  benjaminiHochberg,  shapiro,  tTestPower,  ttest_ind,} from "deepbox/stats";import { tensor } from "deepbox/ndarray";console.log(ttest_ind(tensor([1, 2, 3, 4]), tensor([3, 4, 5, 6])));console.log(shapiro(tensor([1.1, 0.9, 1.0, 1.2, 0.95])));console.log(benjaminiHochberg([0.01, 0.03, 0.2, 0.001], 0.05));console.log(tTestPower({ effectSize: 0.5, alpha: 0.05, power: 0.8 }));