@tpmjs/tools-bootstrap-ci
Calculate bootstrap confidence interval for a sample statistic (mean) using the resampling method. The bootstrap is a powerful non-parametric method that does not assume a normal distribution. It works by repeatedly resampling the data with replacement and calculating the statistic of interest for each resample.
Test @tpmjs/tools-bootstrap-ci (bootstrapCITool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-bootstrap-cipnpm add @tpmjs/tools-bootstrap-ciyarn add @tpmjs/tools-bootstrap-cibun add @tpmjs/tools-bootstrap-cideno add npm:@tpmjs/tools-bootstrap-ciimport { bootstrapCITool } from '@tpmjs/tools-bootstrap-ci';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { bootstrapCITool } from '@tpmjs/tools-bootstrap-ci';
const result = await generateText({
model: openai('gpt-4o'),
tools: { bootstrapCITool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
dataarrayArray of numeric values to analyze (sample data)
confidenceLevelnumberConfidence level as a decimal (e.g., 0.95 for 95% CI). Default: 0.95
iterationsnumberNumber of bootstrap iterations to perform. Default: 1000
Schema extracted: 1/1/2026, 8:17:39 AM
Calculate bootstrap confidence intervals for sample statistics using resampling methodology.
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.
npm install @tpmjs/tools-bootstrap-ci
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]', });
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 // }
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){ 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 }
The bootstrap method is particularly useful when:
For 95% CI: lower bound = 2.5th percentile, upper bound = 97.5th percentile
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, });
MIT
Downloads/month
34
Quality Score