@danielsimonjr/mathts-statistics

中文文档
0.4.13发布于 2026/11/11MITTypeScriptES Module近 30 天下载 2279

Statistics & probability for MathTS — descriptive stats, distributions, hypothesis tests, and combinatorics, every function externally oracle-pinned (SciPy/NumPy/closed-form)

原始使用文档
文档目录4 节
  1. Install
  2. What's included
  3. Example
  4. License

@danielsimonjr/mathts-statistics

Statistics & probability for MathTS — a focused, standalone library covering descriptive statistics, probability distributions, hypothesis tests, and combinatorics.

Every name this package exports is implemented in @danielsimonjr/mathts-functions. This package does not define a second copy of a distribution.

The implementations live in @danielsimonjr/mathts-functions and are re-exported here, not duplicated — this package is a curated entry point over the statistics/probability surface. Every function is externally oracle-pinned (SciPy / NumPy / mpmath / closed form) in the functions package's test suite, so the numbers are trustworthy, not just green.

Install

npm install @danielsimonjr/mathts-statistics

What's included

  • Descriptive statistics — mean, median, mode, variance, std, quantileSeq, mad (median absolute deviation), iqr, sem, zscore, moment, skewness, kurtosis, gmean, hmean, cov, corr, corrcoef, rankdata, ptp, trimmedMean, variation, describe, logsumexp, softmax, detrend, movingAverage, ewma, acf, and the correlation helpers pearsonr, spearman, spearmanr, kendalltau / kendallTau.
  • Parallel reductions — parallelStat* helpers mirror the typed reductions on Float64Array; most op thresholds in ComputePool are 'never' today (inline JS), but the API stays async-friendly where the typed layer returns a Promise. Factory mad is median absolute deviation; parallelStatMAD / parallelStatMeanAD are mean absolute deviation from the mean (not the same statistic). quickSelect / medianSelect / minSelect / maxSelect are synchronous selection utilities.
  • Regression & resampling — linearRegression, polyFit, linregress, pearsonr, spearman, spearmanr, kendalltau, meanCI, proportionCI, bootstrapCI, permutationTest, mahalanobis, hotellingT2, kmeans, spectralClustering.
  • Probability distributions — distribution objects with .pdf/.cdf/.quantile/.mean/.variance/.sample (normalDist, gammaDist, betaDist, binomialDist, poissonDist, exponentialDist, chiSquaredDist, fDist, tDist, logNormalDist, uniformDist, weibullDist, hypergeometricDist, negativeBinomialDist, paretoDist, rayleighDist, triangularDist, discreteUniformDist, gumbelDist, invGaussDist, multivariateNormal), plus free CDF/quantile functions, studentizedRangeCDF / studentizedRangeQuantile, and entropy / jsDivergence.
  • Hypothesis tests — studentTTest (one/two-sample), studentTTestPaired, anova, anova2, chiSquareTest, kolmogorovSmirnovTest + kolmogorovSmirnov2Test, mannWhitneyTest, shapiroWilkTest, leveneTest, bartlettTest, proportionZTest, binomialTest, fTest, jarqueBera, kruskalWallis, wilcoxon, fisherExact, tukeyHSD, andersonDarlingTest, dagostinoTest, friedmanTest, multipleComparison, principalComponentAnalysis.
  • Probability & combinatorics — combinations, combinationsWithRep, permutations, multinomial, factorial, doubleFactorial, risingFactorial, fallingFactorial, subfactorial, bernoulli, gamma, lgamma, kldivergence, and seedable RNG (random, randomInt, pickRandom, seedProbabilityRng).

Example

import {
  anova,
  kendallTau,
  hypergeometricDist,
  kolmogorovSmirnov2Test,
} from '@danielsimonjr/mathts-statistics';

anova([
  [8.1, 8.3, 7.9],
  [9.1, 9.5, 8.9],
]); // one-way ANOVA F + p
kendallTau([1, 2, 3, 4, 5], [2, 1, 4, 3, 5]); // 0.6
hypergeometricDist(50, 5, 10).pdf(1); // 0.4313371972
kolmogorovSmirnov2Test([1, 2, 3], [2, 3, 4]); // { statistic, pValue }

License

MIT

版本与发布记录

@danielsimonjr/mathts-statistics 共发布 87 个版本,首次发布于 2026/06/15;过去 12 个月发布了 87 个版本。

版本发布日期距今
0.4.13latest2026/11/11今天
0.4.122026/11/11今天
0.4.112026/11/11今天
0.4.102026/11/101 天前
0.4.92026/11/101 天前
0.4.82026/11/101 天前

关于 @danielsimonjr/mathts-statistics 的常见问题

@danielsimonjr/mathts-statistics 是什么?

Statistics & probability for MathTS — descriptive stats, distributions, hypothesis tests, and combinatorics, every function externally oracle-pinned (SciPy/NumPy/closed-form)

如何安装 @danielsimonjr/mathts-statistics?

在项目目录运行 npm install @danielsimonjr/mathts-statistics,或使用 pnpm add / yarn add / bun add。

@danielsimonjr/mathts-statistics 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@danielsimonjr/mathts-statistics 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@danielsimonjr/mathts-statistics 可以商用吗?

@danielsimonjr/mathts-statistics 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@danielsimonjr/mathts-statistics 的下载量有多少?

根据 npm 官方下载统计,@danielsimonjr/mathts-statistics 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,279 次,日均约 76 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@danielsimonjr/mathts-statistics 还在维护吗?

最新版本 0.4.13 发布于 2026/11/11(今天);至今共发布 87 个版本,其中过去 12 个月发布了 87 个;首次发布于 2026/06/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。