All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
correlation() - Returns the Pearson correlation coefficient between two arrays (issue #8)covariance() - Returns the population covariance between two arraysmode() - Returns the most frequently occurring value(s)range() - Returns the difference between max and min valuesquartiles() - Returns Q1, Q2 (median), and Q3 valuesgeometricMean() - Returns the geometric mean (nth root of product)harmonicMean() - Returns the harmonic mean (reciprocal of average of reciprocals)RangeError when passed empty arrays (previously some returned 0)TypeError when passed invalid input (NaN, Infinity, non-numbers)median() and percentile() no longer mutate the input arraypercentile() now validates k parameter range (0-1) and throws appropriate errorsaverage() now leverages sum() for DRY principlecount() simplified implementationvariance() calculation optimizedIf you’re upgrading from v0.x, be aware of these breaking changes:
Before (v0.x):
max([]); // returned 0
min([]); // returned 0
sum([]); // returned 0
count([]); // returned 0
percentile([], 0.5); // returned 0
After (v1.0.0):
max([]); // throws RangeError: 'Array cannot be empty'
min([]); // throws RangeError: 'Array cannot be empty'
sum([]); // throws RangeError: 'Array cannot be empty'
count([]); // throws RangeError: 'Array cannot be empty'
percentile([], 0.5); // throws RangeError: 'Array cannot be empty'
Before (v0.x):
max([1, NaN, 3]); // returned NaN or unexpected results
After (v1.0.0):
max([1, NaN, 3]); // throws TypeError: 'All array elements must be finite numbers'
Before (v0.x):
const arr = [3, 1, 2];
median(arr); // arr is now [1, 2, 3] - MUTATED!
After (v1.0.0):
const arr = [3, 1, 2];
median(arr); // arr is still [3, 1, 2] - NOT MUTATED