calc-stats
Advanced tools
Comparing version 0.3.3 to 0.4.0
@@ -17,2 +17,3 @@ const { getOrCreateIterator } = require("iter-fun"); | ||
calcModes = true, | ||
calcRange = true, | ||
calcSum = true | ||
@@ -26,2 +27,4 @@ } = { debugLevel: 0 } | ||
let needSum = calcSum || calcMean; | ||
let needMin = calcMin || calcRange; | ||
let needMax = calcMax || calcRange; | ||
@@ -38,4 +41,4 @@ let count = 0; | ||
if (needCount) count++; | ||
if (calcMin && (min === undefined || value < min)) min = value; | ||
if (calcMax && (max === undefined || value > max)) max = value; | ||
if (needMin && (min === undefined || value < min)) min = value; | ||
if (needMax && (max === undefined || value > max)) max = value; | ||
if (needSum) sum += value; | ||
@@ -76,2 +79,3 @@ if (needHistogram) { | ||
if (calcSum) results.sum = sum; | ||
if (calcRange) results.range = max - min; | ||
if (calcMean) results.mean = sum / count; | ||
@@ -78,0 +82,0 @@ if (calcHistogram) results.histogram = histogram; |
{ | ||
"name": "calc-stats", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"description": "Memory-Aware Statistical Calculations", | ||
@@ -5,0 +5,0 @@ "main": "calc-stats.js", |
@@ -37,2 +37,3 @@ # calc-stats | ||
modes: [90, 100], // all the most popular numbers | ||
range: 99, // the difference between max and min | ||
sum: 328350, | ||
@@ -97,6 +98,7 @@ histogram: { | ||
calcModes: false, | ||
calcRange: true, | ||
calcSum: false | ||
}; | ||
const results = calcStats(data, options); | ||
// results is { min: 1, max: 100 } | ||
// results is { min: 1, max: 100, range: 99 } | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13891
102
103