Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
stats-incremental
Advanced tools
A light statstical package for incremental (i.e. rolling, streaming) sets of numbers.
E.g. given a source of numbers of unknown length that you would like to at any given time know any of:
This module can be used either with Node streams
via a wrapper such as through2
or without being streaming.
Non-streaming:
var Stats = require("stats-incremental")
var dice = require("dice")
var s = Stats()
var rolls = []
for (var i = 0; i < 100; i++) {
s.update(dice.sum(dice.roll("2d6")))
console.log(s.getAll())
}
/* E.g.
{ n: 97,
min: 2,
max: 12,
sum: 673,
mean: 6.938144329896907,
variance: 5.851843979168881,
standard_deviation: 2.419058490233107 }
*/
console.log(s.mean)
console.log(s.standard_deviation)
With streams:
var spigot = require("stream-spigot")
var through2 = require("through2")
var terminus = require("terminus")
var Stats = require("stats-incremental")
var s = Stats()
var statStream = through2.obj(function (chunk, encoding, callback) {
s.update(chunk)
if (s.n % 100000 === 0) {
console.log(s.getAll())
}
this.push(chunk)
callback()
})
spigot.sync({objectMode: true}, Math.random)
.pipe(statStream)
.pipe(terminus.devnull({objectMode: true}))
/*
{ n: 100000,
min: 2.0884908735752106e-7,
max: 0.9999937505926937,
sum: 49861.06196602131,
mean: 0.49861061966021336,
variance: 0.08331362954827709,
standard_deviation: 0.28864100462040576 }
{ n: 200000,
min: 2.0884908735752106e-7,
max: 0.9999937505926937,
sum: 99904.73041411326,
mean: 0.49952365207056687,
variance: 0.08316120223669865,
standard_deviation: 0.2883768406732736 }
*/
var stats = require("stats-incremental")()
Create a new incremental stats aggregator.
stats.update(value)
Update the aggregator with a value. Converted to a Number via parseFloat. If this results in NaN the update is skipped.
stats.getAll()
Get a up-to-date clone of all of the stats stored.
E.g.
{ n: 97,
min: 2,
max: 12,
sum: 673,
mean: 6.938144329896907,
variance: 5.851843979168881,
standard_deviation: 2.419058490233107 }
stats.n
The count of observations.
stats.min
The min value observed.
stats.max
The max value observed.
stats.sum
The sum of all values observed.
stats.mean
The arithmetic mean of the observations.
stats.variance
The variance from the mean.
stats.standard_deviation
The standard deviation of the values from the mean.
stats-lite Operates on complete sets of numbers.
stream-statistics Is a similar module dedicated to streams.
MIT
FAQs
A simple tool for calculating incremental stats on numeric streams.
The npm package stats-incremental receives a total of 421 weekly downloads. As such, stats-incremental popularity was classified as not popular.
We found that stats-incremental demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.