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

statsmodels-js

v0.4.2

Published

basic statistics library.

Readme

statsmodels-js

npm version Build Status Coverage Status License: MIT

A JavaScript implementation of statistics methods.

install

npm install statsmodels-js

How to use

Statistics

basic statistical summary

const Stats = require("statsmodels-js");

const result = Stats.descripeStats([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);

/*
{
  size: 10,
  min: 0,
  max: 9,
  mean: 4.5,
  se: 0.9082951062292475,
  variance: 9.166666666666666,
  skewness: 0,
  kurtosis: -1.2
}
*/

Correlation

Pearson correlation coefficient

const Stats = require("statsmodels-js");

const a = [0, 0, 0, 1, 1, 1, 1];
const b = [0, 1, 2, 3, 4, 5, 6];
const result = Stats.pearsonr(a, b);

/*
{
  r: 0.8660254037844386
  pValue: 0.011724811003882547
}
*/

Similarity

const Stats = require("statsmodels-js");

const a = [1, 1];
const b = [0, 1];
const result1 = Stats.cosSimilarity(a, b);
// 0.7071067811865475

const a = [1, 1];
const b = [1, 1];
const result2 = Stats.cosSimilarity(a, b);
// 1

Statistical Test

unpaired T-Test

const Stats = require("statsmodels-js");

// test assumes that the variances of both populations are equal.
const result1 = Stats.tTestInd([4, 5, 6, 4, 5], [1, 2, 3, 4, 5], true);
/*
  {
    statistic: 2.2499999999999996,
    se: 1.2649110640673518,
    df: 8,
    pValue: 0.054567305799939875
  }
*/

// test doesn't assumes that the variances of both populations are equal.
const result2 = Stats.tTestInd([4, 5, 6, 4, 5], [1, 2, 3, 4, 5], false);
/*
  {
    statistic: 2.2499999999999996,
    se: 0.8,
    df: 6.077151335311573,
    pValue: 0.06488370852885418
  }
*/

T-test for the mean of ONE group of scores.

const result = Stats.tTest1Sample([5, 5, 5, 5, 5, 5, 6, 10], 5.0);
/*
  {
    mean: 5.75,
    sd: 1.6393596310755,
    statistic: 1.2104198771788937,
    pValue: 0.26539803962501435
  }
*/

T-test for 2 related or repeated samples

const result = tTestRel([4, 5, 6, 4, 5], [1, 2, 3, 4, 5]);
/*
  {
    statistic: 2.449489742783178,
    pValue: 0.07048399691022006
  }
*/

Chi-squared test

goodness-of-fit test

const result = chiSqaure([10, 1, 1, 1], [15, 1, 1, 1]);

/*
  {
    statistic: 1.6666666666666667,
    pValue: 0.6443698056370236
  }
*/

test for independence

const result = chi2Contingency([55, 22, 16, 7], [40, 32, 24, 4]);

/*
  {
    statistic: 6.63845472266525,
    pValue: 0.08435923449835192
  }
*/

One-Way ANOVA Test

The one-way ANOVA tests the null hypothesis that two or more groups have the same population mean.

const a = [5, 6, 5, 5, 7];
const b = [6, 6, 7, 5, 6];
const result = Stats.oneWayANOVA(a, b);
// { statistic: 0.6153846153846155, pValue: 0.45536634355271177 }
const a = [66, 62, 80, 50, 57, 68, 73, 65];
const b = [62, 60, 66, 63, 55, 53, 59, 63];
const c = [65, 60, 78, 52, 59, 66, 73, 64];
const d = [52, 59, 44, 67, 47, 53, 58, 49];
const result = oneWayANOVA(a, b, c, d);
/*
  {
    statistic: 4.024870903151017,
    pValue: 0.01685989800789034
  }
*/

Linear Regression

const Stats = require("statsmodels-js");
const x = [1, 2, 3];
const y = [3, 5, 7];

const result = new Stats.SimpleLinearRegression(x, y).fit();
result.summary()
/*
{
  r2Score: 0.9642857142857142,
  coef: 1.5,
  intercept: 0.3333333333333333
}
*/

// prediction
result.predict([10, 20, 30]);
// [ 21, 41, 61 ]
const Stats = require("statsmodels-js");
const x = [
  [10, 20, 30],
  [20, 42, 63],
  [4, 8, 16],
];
const y = [30, 50, 70];

const result = new Stats.MultipleLinearRegression(x, y).fit();
result.summary()
/*
{
  x1: -5.419270833334926,
  x2: -14.610026041665915,
  x3: 11.98828125,
  intercept: 16.74479166666713,
  r2Score: 1
}
*/

/* prediction case 1 */
result.predict([10, 20, 30])
// [[29.999999999999545]]

/* prediction case 2 */
result.predict([
  [10, 20, 30],
  [1, 2, 3],
]);
/*
  [[29.999999999999545], [18.070312500000373]];
*/