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

calc-stats

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calc-stats

Memory-Aware Statistical Calculations

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.6K
increased by19.37%
Maintainers
1
Weekly downloads
 
Created
Source

calc-stats

Memory-Aware Statistical Calculations

motivation

I was looking for a way to calculate statistics for large grid files, including ASCII Grid, GeoTIFF, JPG, JPG2000, and PNG. There were other solutions that worked on numerical arrays. However, those didn't work for my use case because trying to put everything into one array would quickly drain my system's memory. Additionally, some satellite imagery data is so large, it exceeds the maximum length allowed by most JavaScript engines. I needed a solution that could stream the data. However, the other streaming solutions I found, calculate the statistics after each number. For my use case, I don't really care what the sum of half the points are. I only really care about the stats at the end, for all the points. Updating the statistics after each new number was wasted computations and slowed things down. Ultimately, I found it easier to create a new library tailored towards large datasets. Enjoy!

install

npm install calc-stats

usage

import calcStats from "calc-stats";

// data can be an iterator with numerical values
// or something with a built-in iterator like an Array or TypedArray
const results = calcStats(data);
/*
  results is
  {
    min: 1,
    max: 100,
    mean: 66.25,
    median: 70,
    mode: 95, // mean average of the most popular numbers
    modes: [90, 100], // all the most popular numbers
    sum: 328350,
    histogram: {
      '1': {
        n: 1, // numerical value
        ct: 10 // times that the value 1 appears
      },
      .
      .
      .
    }
  });
*/

Keywords

FAQs

Package last updated on 06 Oct 2021

Did you know?

Socket

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.

Install

Related posts

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