0.0.1 • Published 7 years ago
statly v0.0.1
Statly
Statly is a statistics library which is performance-tuned for samples with repeated values. Its methods can accept populations as arrays, but it converts them to value-keyed tally objects.
Install
npm install statlyor
yarn add statlyAPI
tally (Array samples) ➜ Tally counts
Convert an Array to an Tally object, with a key for each unique number in the sample array, and corresponding values indicating the number of times that number appears in the sample array.
Example:
const { tally } = require('statly')
const samples = [ 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4 ]
const counts = tally(samples)
// counts ➜ { 1: 2, 2: 5, 3: 4, 4: 1 }uTest (a: Array|Tally, b: Array|Tally) ➜ { p: Number, auc: Number }
Perform a Mann-Whitney U Test (AKA a Wilcoxon Rank Sum Test) comparing sample a and b.
prepresents the probability that both sets of samples could have been randomly selected from the same underlying distribution.aucis the area under an ROC curve, which corresponds to the portion ofa × bsample pairings in which theavalue is greater than thebvalue.
Example:
const { uTest } = require('statly')
const a = [ 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4 ]
const b = [ 3, 4, 4, 4, 5, 5, 5, 6, 6, 7 ]
const result = uTest(a, b)
// result ➜ { p: 0.0009765625, auc: 0.0375 }