npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sipemu/anofox-statistics

v0.4.1

Published

WebAssembly bindings for anofox-statistics hypothesis testing library

Readme

@sipemu/anofox-statistics

A comprehensive statistical hypothesis testing library compiled to WebAssembly for JavaScript/TypeScript applications. All tests are validated against R.

Installation

npm install @sipemu/anofox-statistics

Usage

Web/Browser

import init, {
  tTest,
  shapiroWilk,
  mannWhitneyU,
  oneWayAnova,
  JsTTestKind,
  JsAlternative,
  JsAnovaKind
} from '@sipemu/anofox-statistics';

// Initialize the WASM module
await init();

// Two-sample t-test
const result = tTest(
  new Float64Array([1.2, 2.3, 3.1, 4.5, 5.2]),
  new Float64Array([2.1, 3.4, 4.2, 5.6, 6.1]),
  JsTTestKind.Welch,
  JsAlternative.TwoSided,
  0.0,  // null hypothesis value
  0.95  // confidence level
);

console.log(result);
// { statistic: -2.34, df: 7.89, p_value: 0.047, mean_x: 3.26, mean_y: 4.28, ... }

Node.js

const { tTest, JsTTestKind, JsAlternative } = require('@sipemu/anofox-statistics');

// Use directly (WASM auto-initializes)
const result = tTest(
  new Float64Array([1.2, 2.3, 3.1]),
  new Float64Array([2.1, 3.4, 4.2]),
  JsTTestKind.Welch,
  JsAlternative.TwoSided
);

Available Tests

Parametric Tests

| Function | Description | |----------|-------------| | tTest | Student's, Welch's, or paired t-test | | yuenTest | Yuen's test for trimmed means (robust) | | oneWayAnova | One-way ANOVA (Fisher or Welch) | | brownForsythe | Brown-Forsythe test for homogeneity of variances |

Nonparametric Tests

| Function | Description | |----------|-------------| | mannWhitneyU | Mann-Whitney U test (Wilcoxon rank-sum) | | wilcoxonSignedRank | Wilcoxon signed-rank test | | kruskalWallis | Kruskal-Wallis H test | | brunnerMunzel | Brunner-Munzel test |

Distributional Tests

| Function | Description | |----------|-------------| | shapiroWilk | Shapiro-Wilk normality test | | kolmogorovSmirnov | Kolmogorov-Smirnov test | | andersonDarling | Anderson-Darling normality test | | jarqueBera | Jarque-Bera normality test |

Categorical Tests

| Function | Description | |----------|-------------| | chiSquaredTest | Chi-squared test for independence | | fisherExact | Fisher's exact test | | binomialTest | Exact binomial test | | mcnemarTest | McNemar's test for paired proportions |

Correlation Tests

| Function | Description | |----------|-------------| | pearsonCorrelation | Pearson correlation with significance | | spearmanCorrelation | Spearman rank correlation | | kendallCorrelation | Kendall's tau correlation | | icc | Intraclass correlation coefficient |

Equivalence Tests (TOST)

| Function | Description | |----------|-------------| | tostTwoSample | TOST for two independent samples | | tostPaired | TOST for paired samples | | tostCorrelation | TOST for correlation equivalence | | tostBootstrap | Bootstrap TOST |

Modern/Kernel Tests

| Function | Description | |----------|-------------| | energyDistanceTest1d | Energy distance test (1D) | | energyDistanceTest | Energy distance test (multivariate) | | mmdTest1d | Maximum Mean Discrepancy test (1D) | | mmdTest | MMD test (multivariate) |

Forecast Comparison Tests

| Function | Description | |----------|-------------| | dieboldMariano | Diebold-Mariano test | | clarkWest | Clark-West test for nested models | | spaTest | Superior Predictive Ability test | | mspeAdjustedSpa | MSPE-adjusted SPA test | | modelConfidenceSet | Model Confidence Set procedure |

Resampling Tests

| Function | Description | |----------|-------------| | permutationTTest | Permutation t-test | | permutationCorrelation | Permutation correlation test | | bootstrapCI | Bootstrap confidence intervals |

Enums

// T-test variants
enum JsTTestKind { Welch, Student, Paired }

// Alternative hypotheses
enum JsAlternative { TwoSided, Less, Greater }

// ANOVA variants
enum JsAnovaKind { Fisher, Welch }

// Kernel types for MMD
enum JsKernel { Gaussian, Laplacian, Linear }

// Loss functions for forecast comparison
enum JsLossFunction { SquaredError, AbsoluteError }

// Variance estimators
enum JsVarEstimator { Acf, Bartlett }

// MCS statistics
enum JsMCSStatistic { Max, Range }

Examples

Normality Testing

import init, { shapiroWilk, andersonDarling } from '@sipemu/anofox-statistics';

await init();

const data = new Float64Array([2.3, 3.1, 2.8, 3.5, 2.9, 3.2, 2.7]);

const sw = shapiroWilk(data);
console.log(`Shapiro-Wilk: W=${sw.statistic.toFixed(4)}, p=${sw.p_value.toFixed(4)}`);

const ad = andersonDarling(data);
console.log(`Anderson-Darling: A=${ad.statistic.toFixed(4)}, p=${ad.p_value.toFixed(4)}`);

ANOVA with Post-hoc

import init, { oneWayAnova, JsAnovaKind } from '@sipemu/anofox-statistics';

await init();

const groups = [
  new Float64Array([23, 25, 28, 31, 27]),
  new Float64Array([31, 33, 35, 37, 34]),
  new Float64Array([41, 43, 45, 47, 44])
];

const result = oneWayAnova(groups, JsAnovaKind.Fisher);
console.log(`F(${result.df_between}, ${result.df_within}) = ${result.statistic.toFixed(2)}`);
console.log(`p-value: ${result.p_value.toFixed(6)}`);

Equivalence Testing (TOST)

import init, { tostTwoSample, JsAlternative } from '@sipemu/anofox-statistics';

await init();

const treatment = new Float64Array([10.2, 11.1, 9.8, 10.5, 10.9]);
const control = new Float64Array([10.0, 10.8, 9.9, 10.3, 10.7]);

// Test equivalence within bounds of -1 to +1
const result = tostTwoSample(treatment, control, -1.0, 1.0, 0.95);
console.log(`Equivalent: ${result.equivalent}`);
console.log(`TOST p-value: ${result.p_value.toFixed(4)}`);

Forecast Model Comparison

import init, {
  dieboldMariano,
  JsLossFunction,
  JsAlternative,
  JsVarEstimator
} from '@sipemu/anofox-statistics';

await init();

const errors1 = new Float64Array([0.5, -0.3, 0.2, -0.1, 0.4]);
const errors2 = new Float64Array([0.3, -0.5, 0.1, 0.2, -0.2]);

const dm = dieboldMariano(
  errors1,
  errors2,
  JsLossFunction.SquaredError,
  1,  // horizon
  JsAlternative.TwoSided,
  JsVarEstimator.Bartlett
);
console.log(`DM statistic: ${dm.statistic.toFixed(4)}, p-value: ${dm.p_value.toFixed(4)}`);

TypeScript Support

Full TypeScript definitions are included. All functions and enums are properly typed:

import init, {
  tTest,
  JsTTestKind,
  JsAlternative
} from '@sipemu/anofox-statistics';

await init();

const result = tTest(
  new Float64Array([1, 2, 3]),
  new Float64Array([4, 5, 6]),
  JsTTestKind.Welch,
  JsAlternative.TwoSided,
  0.0,
  0.95
);

// TypeScript knows result has: statistic, df, p_value, mean_x, mean_y, conf_int, etc.
console.log(result.p_value);

Validation

All statistical tests are validated against R's implementation using extensive test suites. Results match R's output within numerical precision (typically 10^-10).

License

MIT License - see LICENSE for details.

Links