summarystats
v0.3.6
Published
A package to calculate summary statistics
Downloads
1
Maintainers
Readme
summarystats
A lightweight package for summary stats in JavaScript. Please note this package is in the early stage of development. Take care when using it.
Expanded documentation can be found in the functionality wiki.
Installation
So far the package can only be installed through npm. unpkg coming soon.
To install:
npm install summarystats
Functionality
So far, the package can calculate the following stats:
getMean
: Takes an array and returns its mean.getTrimmedMean
: Takes and array and n, where n is the number of items to remove from the beginning and end of the distribution.getMedian
: Takes an array and returns its median.getMode
: Takes and array and returns its mode.getVariance
: Takes an array and returns its variance.isSample
can be used to specify whether the data is a population or sample. By defaultisSample
is set totrue
.getStandDev
: Takes an array and returns its standard deviation.isSample
can be used to specify whether the data is a population or sample. By defaultisSample
is set totrue
.getPercentile
: Takes and array and an nth percentile value and returns thenth
percentile.getQuartiles
: Takes an array and returns the first, middle, and third quartiles.getRange
: Takes an array and returns its range.getIQR
: Takes an array and returns its inter-quartile range.getCoV
: Takes and array and returns its coefficient of variation.getMAD
: Takes and array and returns its median absolute deviation.getZScore
: Takes an array and a value and returns the z-score for the value.getCorrCoeff
: Takes two arrays and calculates their correlation coefficient.getHarmonicMean
: Takes an array and returns the harmonic mean.getGeometricMean
: Takes an array and returns the geometric mean.getStandardError
: Takes an array and returns the standard error.getKurtosis
: Takes an array and returns the kurtosis.getSkewness
: Takes an array and calculates the skewness.
Utilities
matrixArrayIterator
: Utility function to compute a statistic across the axes of an n-dimensional array.
Importing and usage
Functions can be imported individually. For example:
import { getMean } from 'summarystats'
And then called:
const array = [2, 3, 4, 5, 6];
const mean = getMean(array);
Alternatively, the stats
object can be imported:
import stats from 'summarystats'
And then statistical function can be called on this object. This negates the need for multiple imports.
const array = [2, 3, 4, 5, 6];
const mean = stats.getMean(array);