Registry / data / jstat
library1.9.6jsnpmunverified

jStat is a comprehensive JavaScript library providing native implementations of statistical functions, suitable for both browser and Node.js environments. It stands out for offering a wide array of functions for various probability distributions, including Weibull, Cauchy, Poisson, Hypergeometric, and Beta, which are often not found in other similar libraries. For most distributions, jStat includes functions for PDF, CDF, inverse CDF, mean, mode, variance, and sampling. The current stable version is 1.9.6, last published four years ago, indicating a slower release cadence and suggesting potential abandonment. A key point of confusion is its module export structure, exposing `jStat` and `j$` properties within an object rather than as direct exports, which requires specific handling for module loaders like CommonJS and for ESM interoperability. The library also emphasizes browser usage, making the `jStat` object globally available.

npm install jstat
INSTALL
IMPORT
SIG · JSTAT
J
jstat
datajavascriptv1.9.6
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jStat
✓ const { jStat } = require('jstat');
✗ const jStat = require('jstat');
The `jstat` module exports an object containing `jStat` and `j$` properties. Destructure or access them explicitly in CommonJS.
jStat
✓ // <script src='path/to/jstat.min.js'></script> const jstat = window.jStat;
✗ import { jStat } from 'jstat';
When loaded via a script tag in a browser, `jStat` becomes a global property on the `window` object.
jStat
✓ import * as jStatModule from 'jstat'; const jStat = jStatModule.jStat;
✗ import jStat from 'jstat';
j$
✓ const { j$ } = require('jstat');
An alias for `jStat`, also exported from the module object for CommonJS.

Demonstrates importing jStat, calculating basic statistics (mean, standard deviation) from a dataset, using a normal distribution's CDF, and generating a random sample.

import * as jStatModule from 'jstat'; const jStat = jStatModule.jStat; // Define a dataset const dataset = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // Calculate mean and standard deviation const mean = jStat(dataset).mean(); const stdev = jStat(dataset).stdev(); console.log(`Dataset: [${dataset.join(', ')}]`); console.log(`Mean: ${mean}`); console.log(`Standard Deviation: ${stdev}`); // Example of using a distribution function: Normal CDF const normalDist = jStat.normal(mean, stdev); const cdfAt7 = normalDist.cdf(7); console.log(`CDF at x=7 for Normal(${mean.toFixed(2)}, ${stdev.toFixed(2)}): ${cdfAt7.toFixed(4)}`); // Example of generating a sample const sample = normalDist.sample(5); console.log(`Random sample of 5 from Normal(${mean.toFixed(2)}, ${stdev.toFixed(2)}): [${sample.map(s => s.toFixed(2)).join(', ')}]`);
Debug
Known issues
breakingThe npm package name changed from the case-sensitive `jStat` to the all-lowercase `jstat`. Installing `jStat` will lead to an outdated or non-existent package.
fix
Always use `npm install jstat` (lowercase) for installation.
affects: >=1.0.0
gotchaThe `jstat` module does not export its main functionality directly. Instead, it exports an object containing `jStat` and `j$` properties. Direct `require('jstat')` or ESM `import jStat from 'jstat'` will result in an object, not the callable function.
fix
Access the `jStat` (or `j$`) property from the imported module object, e.g., `const { jStat } = require('jstat');` for CommonJS or `import * as jStatModule from 'jstat'; const jStat = jStatModule.jStat;` for ESM.
affects: *
gotchaThe library appears to be largely unmaintained. The last release was over four years ago, and there has been no significant activity on its GitHub repository. This suggests potential risks for security patches, bug fixes, or compatibility with newer JavaScript environments.
fix
Evaluate alternatives if active maintenance, modern features, or ongoing support are critical for your project. Be prepared to fork or maintain it yourself if necessary.
affects: 1.9.6
gotchaWhen used in a browser via a script tag, `jStat` pollutes the global `window` object by adding `window.jStat` and `window.j$`. This can lead to naming conflicts in environments with many global scripts.
fix
Consider using a module bundler (like Webpack or Rollup) to encapsulate the library, or rename the global variable immediately after loading if conflicts are expected.
affects: *
Errors
Common errors & fixes
TypeError: require(...) is not a function
Attempting to call `require('jstat')` directly as a function in CommonJS.
fix
The `jstat` module exports an object. You need to access its `jStat` property: `const { jStat } = require('jstat');`
TypeError: Cannot read properties of undefined (reading 'normal')
`jStat` was not correctly imported or accessed, leading to `jStat` being `undefined` or the wrong object when trying to call a method like `normal()`.
fix
Ensure `jStat` is correctly destructured from the module import: `const { jStat } = require('jstat');` for CJS, or `import * as jStatModule from 'jstat'; const jStat = jStatModule.jStat;` for ESM.
npm ERR! 404 Not Found - GET https://registry.npmjs.org/jStat - Not found
Using the incorrect, case-sensitive package name `jStat` instead of `jstat` during installation.
fix
Install using the correct, all-lowercase package name: `npm install jstat`.
Upgrade
Version history
1.9.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
jstat — npm install jstat · libregistry