Library of react hooks for statistics purpose.
npm install --save stats-hooks
import React, { Component } from 'react'
import { useStats, useFrequency, useFrenquencyValues } from 'stats-hooks'
const App = () => {
const {data, values, ascending, descending, sum, min, max, mean, median, sd} = useStats([1, 3, 2]);
// data : [1, 3, 2]
// values : [1, 3, 2]
// ascending : [1, 2, 3]
// descending : [3, 2, 1]
// sum : 6
// min : 1
// max : 3
// mean : 2
// median : 2
// sd : 0.816496580927726
const frequency = useFrequency([1, 23, 22], 10);
// {lowerBound: 0, upperBound: 10, n: 1}, {lowerBound: 10, upperBound: 20, n: 0}, {lowerBound: 20, upperBound: 30, n: 2}
const frequencyValues = useFrequencyValues(['a', 'b', 'a']);
// {value: 'a', n: 2}, {value: 'b', n: 1}
}
MIT © nubinub