Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stats-lite

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stats-lite - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

4

package.json
{
"name": "stats-lite",
"version": "1.0.0",
"version": "1.0.1",
"description": "A light statistical package that operates on numeric Arrays.",

@@ -39,4 +39,4 @@ "main": "stats.js",

"devDependencies": {
"tape": "~1.0.4"
"tape": "~2.4.0"
}
}

@@ -43,2 +43,4 @@ stats-lite

**NOTE**: This will impact some operations, e.g. `mean([null, 1, 2, 3])` will be calculated as `mean([1, 2, 3])`, (e.g. `6 / 3 = 2`, NOT `6 / 4 = 1.5`)
`numbers(vals)`

@@ -72,3 +74,3 @@ ---

Calculate the [mode](http://en.wikipedia.org/wiki/Mode_(statistics)) average value of vals.
Calculate the [mode](http://en.wikipedia.org/wiki/Mode_statistics) average value of vals.

@@ -75,0 +77,0 @@ `variance(vals)`

@@ -13,7 +13,11 @@ module.exports.numbers = numbers

function numbers(vals) {
if (vals == null) return []
return vals.reduce(function (nums, v) {
if (isNumber(v)) nums.push(+v)
var nums = []
if (vals == null)
return nums
}, [])
for (var i = 0; i < vals.length; i++) {
if (isNumber(vals[i]))
nums.push(+vals[i])
}
return nums
}

@@ -27,3 +31,7 @@

vals = numbers(vals)
return vals.reduce(function (total, val) { return total + val }, 0)
var total = 0
for (var i = 0; i < vals.length; i++) {
total += vals[i]
}
return total
}

@@ -65,3 +73,3 @@

})
var rank = Object.keys(dist).sort(function (a, b) { return dist[b] - dist[a] })
var rank = numbers(Object.keys(dist).sort(function (a, b) { return dist[b] - dist[a] }))
mode = rank[0]

@@ -79,4 +87,7 @@ if (dist[rank[1]] == dist[mode]) {

var avg = mean(vals)
diff = vals.map(function (v) { return Math.pow((v - avg), 2) })
return mean(diff)
var diffs = []
for (var i = 0; i < vals.length; i++) {
diffs.push(Math.pow((vals[i] - avg), 2))
}
return mean(diffs)
}

@@ -83,0 +94,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc