https://github.com/peakk2011/mintstats
Javascript library for statistical calculations
https://github.com/peakk2011/mintstats
data-science data-structures-and-algorithms javascript-data-structures javascript-library library maths peakk2011 static statistics statistics-programming
Last synced: 16 days ago
JSON representation
Javascript library for statistical calculations
- Host: GitHub
- URL: https://github.com/peakk2011/mintstats
- Owner: Peakk2011
- License: mit
- Created: 2025-09-08T12:07:22.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-12-31T04:44:34.000Z (7 months ago)
- Last Synced: 2026-01-04T06:25:42.454Z (6 months ago)
- Topics: data-science, data-structures-and-algorithms, javascript-data-structures, javascript-library, library, maths, peakk2011, static, statistics, statistics-programming
- Language: TypeScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Mint Statistics
A lightweight and fast statistics library for JavaScript and TypeScript.
## Why Mint Stats?
- **5-10x faster** than traditional implementations (Quickselect for median)
- **Fully typed** - Built with TypeScript from the ground up
- **Zero dependencies** - Size: 3.7KB
- **Tree-shakeable** - Import only what you need
## Install
```bash
npm install mintstats
```
## Quick Start
```javascript
import statistics from "mintstats";
const scores = [85, 92, 78, 90, 88];
statistics.mean(scores); // 86.6
statistics.median(scores); // 88
statistics.stdev(scores); // 5.22
// Works with objects too
const students = [
{ name: "Alice", score: 85 },
{ name: "Bob", score: 92 },
];
statistics.mean(students, "score"); // 88.5
statistics.percentile(students, 75, "score"); // 90.5
```
## API
**Basic Stats**
- `mean(arr, key?)` - Average
- `median(arr, key?)` - Middle value (uses Quickselect - O(n))
- `mode(arr, key?)` - Most frequent value(s)
- `range(arr, key?)` - Max - Min
**Variability**
- `variance(arr, options?)` - Variance (sample or population)
- `stdev(arr, options?)` - Standard deviation
- `percentile(arr, p, key?)` - Nth percentile (0-100)
**Options** for variance/stdev:
```javascript
{
key: 'propertyName', // for object arrays
isSample: true // sample (n-1) or population (n)
}
```
## Performance
Benchmark on 10,000 items:
```
Traditional (sort): 588 ops/sec
Mint Stats: 3,438 ops/sec -> 5.85x faster
```
## TypeScript
Full type safety with automatic inference:
```typescript
statistics.mean([1, 2, 3]); // Works
statistics.mean(objects, "value"); // Works
statistics.mean(objects); // Type error - key required
```
## License
MIT © Peakk