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

@tpmjs/tools-permutation-test

v0.2.0

Published

Perform permutation test for difference in means between two groups

Readme

@tpmjs/tools-permutation-test

Perform a permutation test to assess the statistical significance of the difference in means between two groups.

Installation

npm install @tpmjs/tools-permutation-test

Usage

import { permutationTestTool } from '@tpmjs/tools-permutation-test';

// Use with AI SDK
const result = await permutationTestTool.execute({
  group1: [23, 25, 27, 29, 31],
  group2: [18, 20, 22, 24, 26],
  iterations: 10000, // optional, default: 10000
});

console.log(result);
// {
//   pValue: 0.0234,
//   observedDiff: 5,
//   significant: true,
//   iterations: 10000,
//   metadata: {
//     group1Size: 5,
//     group2Size: 5,
//     group1Mean: 27,
//     group2Mean: 22,
//     alpha: 0.05
//   }
// }

Parameters

  • group1 (number[], required): First group of numeric values
  • group2 (number[], required): Second group of numeric values
  • iterations (number, optional): Number of permutations to perform (default: 10000, min: 100, max: 100000)

Returns

{
  pValue: number;              // Two-tailed p-value
  observedDiff: number;        // Absolute difference in means
  significant: boolean;        // Whether p < 0.05
  iterations: number;          // Number of permutations performed
  metadata: {
    group1Size: number;
    group2Size: number;
    group1Mean: number;
    group2Mean: number;
    alpha: number;             // Significance level (0.05)
  }
}

How it works

The permutation test is a non-parametric method that doesn't assume normal distribution:

  1. Calculate the observed difference in means between the two groups
  2. Combine all values from both groups
  3. Randomly shuffle the combined data and split into two groups
  4. Calculate the difference in means for each permutation
  5. Count how many permutations have a difference as extreme or more extreme than observed
  6. Calculate p-value as the proportion of extreme permutations

When to use

  • When you can't assume normal distribution
  • With small sample sizes
  • When comparing means between two independent groups
  • Alternative to t-test when assumptions aren't met

License

MIT