1 | # Simple Statistics
|
2 |
|
3 |
|
4 | A JavaScript implementation of descriptive, regression, and inference statistics.
|
5 |
|
6 | [![codecov.io](https://codecov.io/github/simple-statistics/simple-statistics/coverage.svg?branch=master)](https://codecov.io/github/simple-statistics/simple-statistics?branch=master)
|
7 | [![npm version](https://badge.fury.io/js/simple-statistics.svg)](http://badge.fury.io/js/simple-statistics)
|
8 |
|
9 | Implemented in literate JavaScript with no dependencies, designed to work
|
10 | in all modern browsers (including IE) as well as in [node.js](https://nodejs.org/).
|
11 |
|
12 | * :green_book: [API Documentation](http://simplestatistics.org/docs/)
|
13 | * :chart_with_upwards_trend: [Benchmarks](./benchmarks/)
|
14 | * :kissing: [A list of other statistics libraries](./SEEALSO.md)
|
15 |
|
16 | ## Installation
|
17 |
|
18 | * **I'm using Node.js, Webpack, Browserify, Rollup, or another module bundler,
|
19 | and install packages from npm.**
|
20 | * First, install the `simple-statistics` module, using `npm install simple-statistics`,
|
21 | then include the code with require or import:
|
22 | * **I use the `require` function to use modules in my project. (most likely)**
|
23 | * When you use `require`, you have the freedom to assign the module to any
|
24 | variable name you want, but you need to specify the module's name exactly:
|
25 | in this case, 'simple-statistics'. The `require` method returns an object
|
26 | with all of the module's methods attached to it.<br /> <pre>var ss = require('simple-statistics')</pre>
|
27 | * **I use `import` to use modules in my project. I'm probably using Babel, `@std/esm`, Webpack, or Rollup.**
|
28 | * Import all functions under the ss object: <pre>import * as ss from 'simple-statistics'</pre>
|
29 | Include a specific named export: <pre>import {min} from 'simple-statistics'</pre>
|
30 | Simple statistics has _only_ named exports for ES6.
|
31 | * **I'm not using a module bundler. I'm writing a web page, and want to include
|
32 | simple-statistics using a script tag.**
|
33 | * **I want to support all browsers**
|
34 | * When you use simple-statistics from a script tag, you don't get to choose
|
35 | the variable name it is assigned to: simple-statistics will always become
|
36 | available globally as the variable `ss`. You can reassign this variable to
|
37 | another name if you want to, but doing so is optional.
|
38 | ```HTML
|
39 | <script src='https://unpkg.com/simple-statistics@7.0.7/dist/simple-statistics.min.js'>
|
40 | </script>
|
41 | ```
|
42 | * **I want to use ES6 modules in a browser and I'm [willing to only support new browsers](https://caniuse.com/#feat=es6-module) to do it**
|
43 | * This module works great with the [`?module`](https://unpkg.com/#/query-parameters) query parameter of unpkg. If you
|
44 | specify `type='module'` in your script tag, you'll be able to import simple-statistics
|
45 | directly - through `index.js` and with true [ES6 import syntax and behavior](http://exploringjs.com/es6/ch_modules.html).
|
46 | ```js
|
47 | <script type='module'>
|
48 | import {min} from "https://unpkg.com/simple-statistics@7.0.7/index.js?module"
|
49 | console.log(min([1, 2, 3]))
|
50 | </script>
|
51 | ```
|
52 | This feature is still experimental in unpkg and very bleeding-edge.
|