bankers-math
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -33,5 +33,20 @@ | ||
}) | ||
return Services.toFixedNumber( Math.sqrt( squareDiffs.reduce((acc, current) => acc + current, 0) / list.length ), 6 ) | ||
return Math.sqrt( squareDiffs.reduce((acc, current) => acc + current, 0) / list.length ) | ||
}, | ||
analyseValues ( list, decimalPlaces = 6 ) { | ||
let sum = Services.sum(list) | ||
let avg = Services.toFixedNumber( list.length > 0 ? sum / list.length : 0, decimalPlaces ) | ||
const squareDiffs = list.map((value) => { | ||
const diff = value - avg; | ||
return diff * diff; | ||
}) | ||
let variance = Services.toFixedNumber( Math.sqrt( squareDiffs.reduce((acc, current) => acc + current, 0) / list.length ), decimalPlaces ) | ||
return { | ||
sum, | ||
avg, | ||
variance | ||
} | ||
}, | ||
defined (value) { | ||
@@ -38,0 +53,0 @@ return value !== undefined && value !== null |
{ | ||
"name": "bankers-math", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Helper function for Bankers' calculus", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
12286
330