stats-lite
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "stats-lite", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "A light statistical package that operates on numeric Arrays.", | ||
@@ -5,0 +5,0 @@ "main": "stats.js", |
@@ -97,3 +97,3 @@ stats-lite | ||
Calculate the value reprecenting the desired [percentile](http://en.wikipedia.org/wiki/Percentile) `(0 < ptile <= 1)`. Uses the Estimation method to interpolate non-member percentiles. | ||
Calculate the value representing the desired [percentile](http://en.wikipedia.org/wiki/Percentile) `(0 < ptile <= 1)`. Uses the Estimation method to interpolate non-member percentiles. | ||
@@ -100,0 +100,0 @@ LICENSE |
42
stats.js
@@ -15,7 +15,7 @@ "use strict"; | ||
function numbers(vals) { | ||
let nums = [] | ||
var nums = [] | ||
if (vals == null) | ||
return nums | ||
for (let i = 0; i < vals.length; i++) { | ||
for (var i = 0; i < vals.length; i++) { | ||
if (isNumber(vals[i])) | ||
@@ -33,4 +33,4 @@ nums.push(+vals[i]) | ||
vals = numbers(vals) | ||
let total = 0 | ||
for (let i = 0; i < vals.length; i++) { | ||
var total = 0 | ||
for (var i = 0; i < vals.length; i++) { | ||
total += vals[i] | ||
@@ -51,3 +51,3 @@ } | ||
let half = (vals.length / 2) | 0 | ||
var half = (vals.length / 2) | 0 | ||
@@ -70,8 +70,8 @@ vals = nsort(vals) | ||
if (vals.length === 0) return NaN | ||
let mode = NaN | ||
let dist = {} | ||
var mode = NaN | ||
var dist = {} | ||
for (let i = 0; i < vals.length; i++) { | ||
let value = vals[i] | ||
let me = dist[value] || 0 | ||
for (var i = 0; i < vals.length; i++) { | ||
var value = vals[i] | ||
var me = dist[value] || 0 | ||
me++ | ||
@@ -81,3 +81,3 @@ dist[value] = me | ||
let rank = numbers(Object.keys(dist).sort(function sortMembers(a, b) { return dist[b] - dist[a] })) | ||
var rank = numbers(Object.keys(dist).sort(function sortMembers(a, b) { return dist[b] - dist[a] })) | ||
mode = rank[0] | ||
@@ -90,5 +90,5 @@ if (dist[rank[1]] == dist[mode]) { | ||
} | ||
let modes = new Set([mode]) | ||
let modeCount = dist[mode] | ||
for (let i = 1; i < rank.length; i++) { | ||
var modes = new Set([mode]) | ||
var modeCount = dist[mode] | ||
for (var i = 1; i < rank.length; i++) { | ||
if (dist[rank[i]] == modeCount) { | ||
@@ -109,5 +109,5 @@ modes.add(rank[i]) | ||
vals = numbers(vals) | ||
let avg = mean(vals) | ||
let diffs = [] | ||
for (let i = 0; i < vals.length; i++) { | ||
var avg = mean(vals) | ||
var diffs = [] | ||
for (var i = 0; i < vals.length; i++) { | ||
diffs.push(Math.pow((vals[i] - avg), 2)) | ||
@@ -130,8 +130,8 @@ } | ||
vals = nsort(vals) | ||
let i = (vals.length * ptile) - 0.5 | ||
var i = (vals.length * ptile) - 0.5 | ||
if ((i | 0) === i) return vals[i] | ||
// interpolated percentile -- using Estimation method | ||
let int_part = i | 0 | ||
let fract = i - int_part | ||
return (1 - fract) * vals[int_part] + fract * vals[int_part + 1] | ||
var int_part = i | 0 | ||
var fract = i - int_part | ||
return (1 - fract) * vals[int_part] + fract * vals[Math.min(int_part + 1, vals.length - 1)] | ||
} |
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
7658