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-bootstrap-ci

v0.2.0

Published

Calculate bootstrap confidence intervals for sample statistics using resampling

Readme

@tpmjs/tools-bootstrap-ci

Calculate bootstrap confidence intervals for sample statistics using resampling methodology.

Overview

The bootstrap is a powerful non-parametric statistical method for estimating confidence intervals without assuming any specific distribution (like normal distribution). It works by repeatedly resampling the data with replacement and calculating the statistic of interest for each resample.

This tool implements the percentile method for bootstrap confidence intervals, which directly uses the percentiles of the bootstrap distribution.

Installation

npm install @tpmjs/tools-bootstrap-ci

Usage with AI SDK

import { bootstrapCITool } from '@tpmjs/tools-bootstrap-ci';
import { generateText } from 'ai';

const result = await generateText({
  model: yourModel,
  tools: { bootstrapCI: bootstrapCITool },
  toolChoice: 'required',
  prompt: 'Calculate a 95% confidence interval for this sample: [23, 25, 28, 22, 24, 26, 29, 27, 25, 24]',
});

Direct Usage

import { bootstrapCITool } from '@tpmjs/tools-bootstrap-ci';

const result = await bootstrapCITool.execute({
  data: [23, 25, 28, 22, 24, 26, 29, 27, 25, 24],
  confidenceLevel: 0.95,
  iterations: 1000,
});

console.log(result);
// {
//   mean: 25.3,
//   lower: 24.1,
//   upper: 26.5,
//   confidenceLevel: 0.95,
//   iterations: 1000,
//   sampleSize: 10
// }

Parameters

  • data (required): Array of numeric values to analyze (minimum 2 values)
  • confidenceLevel (optional): Confidence level as decimal (default: 0.95 for 95% CI, range: 0.5-0.999)
  • iterations (optional): Number of bootstrap resamples (default: 1000, range: 100-100,000)

Returns

{
  mean: number;           // Original sample mean
  lower: number;          // Lower bound of confidence interval
  upper: number;          // Upper bound of confidence interval
  confidenceLevel: number; // Confidence level used
  iterations: number;     // Number of bootstrap iterations performed
  sampleSize: number;     // Size of original sample
}

When to Use Bootstrap CI

The bootstrap method is particularly useful when:

  • Your sample size is small to moderate
  • You don't know the underlying distribution of your data
  • The traditional parametric methods (t-test) assumptions might be violated
  • You want a robust, assumption-free confidence interval

Algorithm

  1. Calculate the mean of the original sample
  2. Generate N bootstrap samples by randomly sampling with replacement
  3. Calculate the mean for each bootstrap sample
  4. Sort all bootstrap means
  5. Use percentiles to determine confidence interval bounds

For 95% CI: lower bound = 2.5th percentile, upper bound = 97.5th percentile

Example Use Cases

Small sample analysis:

const clinicalTrialData = [5.2, 6.1, 4.8, 5.9, 6.3, 5.5];
const ci = await bootstrapCITool.execute({ data: clinicalTrialData });

Different confidence levels:

// 99% confidence interval
const ci99 = await bootstrapCITool.execute({
  data: measurements,
  confidenceLevel: 0.99,
});

// 90% confidence interval
const ci90 = await bootstrapCITool.execute({
  data: measurements,
  confidenceLevel: 0.90,
});

High precision analysis:

// Use more iterations for more precise estimates
const preciseCI = await bootstrapCITool.execute({
  data: sampleData,
  iterations: 10000,
});

Limitations

  • Computational intensity increases with iterations (trade-off between precision and speed)
  • Results may vary slightly between runs due to random sampling (use more iterations for stability)
  • Best suited for estimating means; other statistics may require modified approaches

References

  • Efron, B., & Tibshirani, R. J. (1994). An Introduction to the Bootstrap
  • DiCiccio, T. J., & Efron, B. (1996). Bootstrap confidence intervals. Statistical Science, 11(3), 189-228

License

MIT