GithubHelp home page GithubHelp logo

simple-statistics / simple-statistics Goto Github PK

View Code? Open in Web Editor NEW
3.3K 3.3K 224.0 3.51 MB

simple statistics for node & browser javascript

Home Page: http://simplestatistics.org/

License: ISC License

JavaScript 98.22% Shell 0.11% TypeScript 1.67%
javascript math regression statistics

simple-statistics's Introduction

Simple Statistics

A JavaScript implementation of descriptive, regression, and inference statistics.

Coverage Status npm version

Implemented in literate JavaScript with no dependencies, designed to work in all modern browsers (including IE) as well as in node.js.

Installation

  • I'm using Node.js, Webpack, Browserify, Rollup, or another module bundler, and install packages from npm.
    • First, install the simple-statistics module, using npm install simple-statistics, then include the code with require or import:
    • I use the require function to use modules in my project. (most likely)
      • When you use require, you have the freedom to assign the module to any variable name you want, but you need to specify the module's name exactly: in this case, 'simple-statistics'. The require method returns an object with all of the module's methods attached to it.
        var ss = require('simple-statistics')
    • I use import to use modules in my project. I'm probably using Babel, @std/esm, Webpack, or Rollup.
      • Import all functions under the ss object:
        import * as ss from 'simple-statistics'
        Include a specific named export:
        import {min} from 'simple-statistics'
        Simple statistics has only named exports for ES6.
  • I'm using Deno.
  • I'm not using a module bundler. I'm writing a web page, and want to include simple-statistics using a script tag.
    • I want to support all browsers
      • When you use simple-statistics from a script tag, you don't get to choose the variable name it is assigned to: simple-statistics will always become available globally as the variable ss. You can reassign this variable to another name if you want to, but doing so is optional.
        <script src='https://unpkg.com/[email protected]/dist/simple-statistics.min.js'>
        </script>
    • I want to use ES6 modules in a browser and I'm willing to only support new browsers to do it
      • This module works great with the ?module query parameter of unpkg. If you specify type='module' in your script tag, you'll be able to import simple-statistics directly - through index.js and with true ES6 import syntax and behavior.
        <script type='module'>
        import {min} from "https://unpkg.com/[email protected]/index.js?module"
        console.log(min([1, 2, 3]))
        </script>
        This feature is still experimental in unpkg and very bleeding-edge.

simple-statistics's People

Contributors

ajschumacher avatar altearius avatar danallison avatar deniscarriere avatar dependabot-preview[bot] avatar dependabot[bot] avatar dsaxton avatar e-n-f avatar emanuelfeld avatar erictheise avatar fil avatar greenkeeper[bot] avatar harunorimurata avatar joker-vd avatar jseppi avatar jthomm avatar jwilber avatar kyleamathews avatar llimllib avatar mattsacks avatar mourner avatar phoeagon avatar rluta avatar rzoller avatar schnerd avatar siculars avatar tmcw avatar tniessen avatar xuefeng-zhu avatar yomguithereal 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-statistics's Issues

Tag 1.0.0

This has been stable for a long time and I'm comfortable with the layout of the API. I should tag 1.0.0.

R-squared of a linear regression

Hello:

Mostly a question ... Is there an easy way to get the R-squared of a ss linear regression? I see that R-squared can be calculated separately, but wondering how to put the two together.

equal interval classification

Like jenks, but splits on equal intervals. Might be too trivial, but I have been finding myself building this out all the time when using ss.

Bump version

Great library; thanks for the awesome work. If its not too much trouble, can you create a new tag (like 0.1.1 or whatever you think is appropriate). The main reason that I ask is that Bower doesn't really like handling branches that I can see. Many thanks.

equal number of features

Like jenks, but splits on equal number of features. I find this is often an alternative to jenks.

5 breaks:

[1,1,1,2,2,3,4,4,4,5]
=>
[1,1],[1,2],[2,3],[4,4],[4,5]

Streamy statistics

Many of the methods here would be amenable to stream-interface, so that they can adjust to new input. This is likely a new module.

Weighted linear regression

Hi

Do you, by any chance, know where I can find a Javascript library for weighted linear regression? If not, would you consider adding it to simple-statistics?

Thanks

Marcus

question : variance or sample variance?

I read your code and I didn't understand what is the difference between variance and sample variance. is it just the different value of denominator? I would expect that sample variance is a variance calculated on a subset.

Thanks

Create homepage

This has nothing in index.js: it should have an intro or something.

AMD

it's simple enough to support AMD too, should be a 3-line change.

Quantile not quantiling

@tmcw @morganherlocker As is my wont, I have probably screwed up something basic, but I've been using ss_quantile() in what I think is the correct manner to classify data on a map, and I'm not getting equal numbers per bin.

Here's the implementation (adapted from the now-classic Leaflet choropleth example of yore):

// FORMAT COLOR SCHEME BY QUANTILE
function getColorPositive(d) {
  return d > 100 ? 'rgba(0,0,0,0)'
    : d >= ss.quantile(range,0.8) && d < 100 ? '#4682b4'
    : d >= ss.quantile(range,0.6) && d < ss.quantile(range,0.8) ? '#7a9fc7'
    : d >= ss.quantile(range,0.4) && d < ss.quantile(range,0.6) ? '#a7bfd9'
    : d >= ss.quantile(range,0.2) && d < ss.quantile(range,0.4) ? '#d4deec'
    : '#ffffff';
}

Here's an example of the range array:

[0.2271, 0.1937, 0.2017, 0.1092, 0.1401, 0.2652, 0.1757, undefined, 0.2026, 0.193, 0.1526, 0.3377, undefined, 0.2196, 0.1244, 0.1393, 0.1792, 0.4396, 0.1892, 0.2097, 0.2016, 0.1989, 0.259, undefined, undefined, 0.1836, undefined, 0.1684, 0.1412, 0.2843, undefined, undefined, 0.182, 0.176, 0.1228, 0.1085, 0.1032, 0.299, 0.1762, 0.2347, 0.2213, 0.333, 0.294, 0.2503, 0.2965, 0.2017, 0.1781, undefined, 0.2886, 0.2557, 0.1859, 0.2629, 0.1728, 0.1331, 0.26, 0.1627]`

And here's what it looks like on the map (with the above range):
2014-10-21_2208
. . . there are three of the dark red-binned features and twelve of the white-binned features; there should be 8-9 features per color bin. This happens pretty consistently for all the red-colored variables in the app.

What did I screw up?

Calculations incorrect.

console.log(stat.variance([1,2.0,3,4,5,6,7]))
4
console.log(stat.standard_deviation([1,2,3.0,4,5,6,7]))
2

sample function

Add sample function to reduce the time it takes to operate on larger data sets

split into files

there are enough functions in here that it makes sense to do this now.

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.