bankers-math
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -21,2 +21,17 @@ | ||
sum (list) { | ||
return list.length > 0 ? list.reduce((acc, current) => acc + current, 0) : 0 | ||
}, | ||
avg (list) { | ||
return list.length > 0 ? Services.sum(list) / list.length : 0 | ||
}, | ||
variance (list) { | ||
let avg = Services.avg(list) | ||
const squareDiffs = list.map((value) => { | ||
const diff = value - avg; | ||
return diff * diff; | ||
}) | ||
return Services.toFixedNumber( Math.sqrt( squareDiffs.reduce((acc, current) => acc + current, 0) / list.length ), 6 ) | ||
}, | ||
defined (value) { | ||
@@ -23,0 +38,0 @@ return value !== undefined && value !== null |
{ | ||
"name": "bankers-math", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Helper function for Bankers' calculus", | ||
@@ -25,3 +25,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"jest": "^29.6.2" | ||
"jest": "^29.7.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "engines": { |
@@ -30,2 +30,5 @@ const Services = require( '../Banker' ) | ||
} ) | ||
test('Diffraction', async function () { | ||
console.log( Services.variance( [ 100, 120, 80 ] ) ) | ||
} ) | ||
} ) |
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
11857
316