Giter Club home page Giter Club logo

wink-statistics's Introduction

wink-statistics

Fast and Numerically Stable Statistical Analysis Utilities

Build Status Coverage Status Inline docs dependencies Status devDependencies Status Gitter

Perform fast and numerically stable statistical analysis using wink-statistics. It can handle real-time stream of data and can incrementally compute required statistic that usually would take more than one pass over the data as in standard deviation or simple linear regression.

Functions

  1. Boxplot
  2. Covariance
  3. Difference with definable lag
  4. Five Number Summary
  5. Frequency Table
  6. Histogram
  7. Median Absolute Deviation (MAD)
  8. Maximum
  9. Mean
  10. Median
  11. Minimum
  12. Numerically stable sum
  13. Percentile
  14. Probability computation & CI from successes count
  15. Probability estimates aggregation
  16. Simple Linear Regression
  17. Standard Deviation
  18. Summary statistics

Installation

Use npm to install:

npm install wink-statistics --save

Getting Started

Handling Streams

Here is an example of computing slope, intercept and r2 etc. from a stream of (x, y) data in real-time:

// Load wink-statistics.
var stats = require( 'wink-statistics' );
// Instantiate streaming simple linear regression
var regression = stats.streaming.simpleLinearRegression();
// Following would be ideally placed within a stream of data:
regression.compute( 10, 80 );
regression.compute( 15, 75 );
regression.compute( 16, 65 );
regression.compute( 18, 50 );
regression.compute( 21, 45 );
regression.compute( 30, 30 );
regression.compute( 36, 18 );
regression.compute( 40, 9 );
// Use result() method to access the outcome in real time.
regression.result();
// returns { slope: -2.3621,
//   intercept: 101.4188,
//   r: -0.9766,
//   r2: 0.9537,
//   se: 5.624,
//   size: 8
// }

Handling data array

The functions under the data name space require data in an array. Here is an example of boxplot analysis:

var boxplot = stats.data.boxplot;
var data = [
  -12, 14, 14, 14, 16, 18, 20, 20, 21, 23, 27, 27, 27, 29, 31,
  31, 32, 32, 34, 36, 40, 40, 40, 40, 40, 42, 51, 56, 60, 88
];

boxplot( data );
// returns {
//   min: -12, q1: 20, median: 31, q3: 40, max: 88,
//   iqr: 20, range: 100, size: 30,
//   leftOutliers: { begin: 0, end: 0, count: 1, fence: 14 },
//   rightOutliers: { begin: 29, end: 29, count: 1, fence: 60 },
//   leftNotch: 25.230655727612252,
//   rightNotch: 36.76934427238775
// }

wink-stats can handle data in different formats to avoid pre-processing. For example, you can compute median from the array of objects containing value:

var median = stats.data.median;
var data =  [
  { value: 1 },
  { value: 1 },
  { value: 2 },
  { value: 2 },
  { value: 3 },
  { value: 3 },
  { value: 4 },
  { value: 4 }
];
// Use key name — `value` as the `accessor`
median( data, 'value' );
// returns 2.5

It even supports passing functions as accessors to handle even more complex data structures.

Documentation

Check out the statistics API documentation to learn more.

Need Help?

If you spot a bug and the same has not yet been reported, raise a new issue or consider fixing it and sending a pull request.

About wink

Wink is a family of open source packages for Statistical Analysis, Natural Language Processing and Machine Learning in NodeJS. The code is thoroughly documented for easy human comprehension and has a test coverage of ~100% for reliability to build production grade solutions.

Copyright & License

wink-statistics is copyright 2017-20 GRAYPE Systems Private Limited.

It is licensed under the terms of the MIT License.

wink-statistics's People

Contributors

prtksxna avatar sanjayaksaxena avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wink-statistics's Issues

custom beans in histogram

actually its not an issue, but a contribution:

there is no way to make custom bins, so i did this:

var histogram = function ( sortedData, dataPrecision, accessor, maxBins = null ) {

and before choose between Freedman–Diaconis or Sturges' Rule:

    // Compute `bins` and `binWidth`.
    if ((binWidth === 0)) {
        rs.mad = mad(sortedData, accessor);
        binWidth = 2 * rs.mad;
    }

    // start custom code
    if (maxBins){
        if (binWidth > maxBins){
            binWidth = maxBins;
        }
    }
    // end custom code

    if (binWidth > 0) {

better to read like this if you are using it to make a graph.

cheers and sorry my bad english.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.