# student-histogram

> Record a sample and compute its statistical significance

Latest version **2.0.0** (published 2022-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install student-histogram
pnpm add student-histogram
yarn add student-histogram
bun add student-histogram
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-11-01 |
| First published | 2017-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16 |
| Dependencies | 4 |
| Unpacked size | 10.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Vincent Weevers |
| Maintainers | vweevers |
| Keywords | benchmark, distribution, hdr-histogram, histogram, sample, student, student-t |

## Links

- npm: https://www.npmjs.com/package/student-histogram
- Repository: https://github.com/vweevers/student-histogram
- Issues: https://github.com/vweevers/student-histogram/issues
- npm.io page: https://npm.io/package/student-histogram

## Dependencies (4)

- [big.js](https://npm.io/package/big.js.md) ^6.2.1
- [int64-buffer](https://npm.io/package/int64-buffer.md) ^1.0.1
- [sample-sizer](https://npm.io/package/sample-sizer.md) 0.1.0
- [native-hdr-histogram](https://npm.io/package/native-hdr-histogram.md) ^1.0.0

## Recent versions

- 2.0.0 (latest) — 2022-11-01
- 1.0.0 — 2019-06-29
- 0.1.0 — 2018-09-11
- 0.0.2 — 2017-10-24

## README

# student-histogram

**Record a sample and compute its statistical significance.** Uses [`native-hdr-histogram`][native-hdr-histogram] and a two-tailed t-distribution table under the hood. Good for sample sizes below 200. HDR histogram is designed for "value measurements in latency and performance sensitive applications", quantizes values with a configurable precision and has a constant memory footprint.

[![npm](https://img.shields.io/npm/v/student-histogram.svg)](https://www.npmjs.com/package/student-histogram)
[![Node version](https://img.shields.io/node/v/student-histogram.svg)](https://www.npmjs.com/package/student-histogram)
[![Test](https://img.shields.io/github/workflow/status/vweevers/student-histogram/Test?label=test)](https://github.com/vweevers/student-histogram/actions/workflows/test.yml)
[![Standard](https://img.shields.io/badge/standard-informational?logo=javascript&logoColor=fff)](https://standardjs.com)

## Example

```js
const StudentHistogram = require('student-histogram')
const h = new StudentHistogram(1, 200, 3)

// Record some example values.
const sample = [100, 120, 101, 103, 99]
sample.forEach(v => h.record(v))

const log = console.log
const percent = require('fixed-number')(1, 2, 'percent')

log('arithmetic mean            : %d ±%s', h.mean(), percent(h.rme()))
log('standard deviation         :', h.stddev())
log('minimum and maximum        : %d and %d', h.min(), h.max())
log('75% of values fall below   :', h.percentile(75))
log()

log('standard error of the mean :', h.sem())
log('margin of error            :', h.moe())
log('relative margin of error   :', h.rme())
log('with higher confidence     :', h.rme(0.998))
log()

// Estimate the size (number of sampling points aka recorded values)
// that is required to achieve a relative margin of error of 0.05.
log('recommended sample size    :', h.minimumSize(0.05))
log('for 99.5% confidence       :', h.minimumSize(0.05, 0.995))
log('with 10% error tolerance   :', h.minimumSize(0.10))

if (h.size < h.minimumSize(0.05)) {
  // Maybe record some more!
}
```

Output:

```
arithmetic mean            : 104.6 ±9.27%
standard deviation         : 7.812809993849844
minimum and maximum        : 99 and 120
75% of values fall below   : 103

standard error of the mean : 3.493994848307593
margin of error            : 9.700727296841201
relative margin of error   : 0.09274117874609179
with higher confidence     : 0.23960921458776316

recommended sample size    : 18
for 99.5% confidence       : 70
with 10% error tolerance   : 5
```

## API

### `StudentHistogram(min, max, figures, opts)`

Documentation to follow.

## Install

With [npm](https://npmjs.org) do:

```
npm install student-histogram
```

## See also

- [`hdr-histogram-percentiles-obj`][hdr-histogram-percentiles-obj] (`student-histogram` is compatible)

## License

[MIT](LICENSE) © 2017-present Vincent Weevers. Based in part on [`benchmark.js`][benchmark-js] and [`sample-sizer`][sample-sizer]. See included [`LICENSE`](LICENSE) file for all copyright owners.

[benchmark-js]: https://github.com/bestiejs/benchmark.js
[sample-sizer]: https://github.com/mapbox/sample-sizer
[native-hdr-histogram]: https://github.com/mcollina/native-hdr-histogram
[hdr-histogram-percentiles-obj]: https://github.com/thekemkid/hdr-histogram-percentiles-obj

---
_Source: https://npm.io/package/student-histogram · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
