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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@addmaple/stats

v0.1.1

Published

High-performance statistics library built with Rust and WebAssembly

Downloads

186

Readme

@addmaple/stats

High-performance statistics library built with Rust and WebAssembly, designed to be a modern, fast alternative to jStat.

Installation

npm install @addmaple/stats

Quick Start

import { init, mean, variance, stdev } from '@addmaple/stats';

// Initialize WASM module (required once)
await init();

// Use statistics functions
const data = [1, 2, 3, 4, 5];
const m = mean(data);        // 3
const v = variance(data);     // 2
const s = stdev(data);        // 1.414...

Features

✅ Vector Statistics

  • Basic operations: sum, mean, min, max, product, range
  • Variance & standard deviation: variance, sampleVariance, stdev, sampleStdev, coeffvar
  • Advanced statistics: median, mode, geomean, skewness, kurtosis
  • Transformations: cumsum, cumprod, diff, rank, histogram

✅ Distributions

  • Normal, Gamma, Beta, Student's t, Chi-squared, Fisher F, Exponential, Poisson, Binomial, Uniform, Cauchy, Laplace, Log-normal, Weibull, Pareto, Triangular, Inverse Gamma, Negative Binomial
  • Each distribution supports: pdf, cdf, inv (inverse CDF)
  • Scalar and array operations

✅ Quantiles & Percentiles

  • percentile, percentileOfScore, quartiles, iqr, quantiles

✅ Correlation & Covariance

  • covariance - Covariance between two arrays
  • corrcoeff - Pearson correlation coefficient
  • spearmancoeff - Spearman rank correlation

✅ Statistical Tests

  • ttest, ztest, regress, normalci, tci, chiSquareTest, anovaTest, and more

Tree-Shaking Support

Import only what you need to reduce bundle size:

// Only loads stats module: ~20KB (gzipped)
import { init, mean, variance } from '@addmaple/stats/stats';
await init();

// Only loads distributions module: ~42KB (gzipped)
import { init, normal, poisson } from '@addmaple/stats/distributions';
await init();

// Only loads quantiles module: ~13KB (gzipped)
import { init, percentile, quartiles } from '@addmaple/stats/quantiles';
await init();

// Only loads correlation module: ~11KB (gzipped)
import { init, covariance, corrcoeff } from '@addmaple/stats/correlation';
await init();

// Only loads tests module: ~20KB (gzipped)
import { init, ttest, regress } from '@addmaple/stats/tests';
await init();

// Full module: ~77KB (gzipped)
import { init, mean, normal } from '@addmaple/stats';
await init();

Examples

Basic Statistics

import { init, mean, variance, stdev, median } from '@addmaple/stats';
await init();

const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
console.log(mean(data));      // 5.5
console.log(variance(data));   // 8.25
console.log(stdev(data));     // 2.872...
console.log(median(data));    // 5.5

Distributions

import { init, normal } from '@addmaple/stats';
await init();

const dist = normal({ mean: 0, sd: 1 });
console.log(dist.pdf(0));     // 0.3989...
console.log(dist.cdf(1.96));  // 0.9750...
console.log(dist.inv(0.975)); // ~1.96

Correlation

import { init, corrcoeff } from '@addmaple/stats';
await init();

const x = [1, 2, 3, 4, 5];
const y = [2, 4, 6, 8, 10];
console.log(corrcoeff(x, y)); // 1.0

Performance

This library uses SIMD-optimized Rust code compiled to WebAssembly, delivering exceptional performance compared to pure JavaScript implementations.

Browser Support

Works in all modern browsers that support WebAssembly. For Node.js, requires Node.js 18+.

License

MIT