|
1 |
| -[jStat](http://www.jstat.org/) - JavaScript Statistical Library |
| 1 | +**@handsontable/jstat** - JavaScript Statistical Library |
2 | 2 | ===============================================================
|
3 | 3 |
|
4 |
| -[](https://badge.fury.io/js/jStat) |
5 |
| - |
6 |
| -jStat provides native javascript implementations of statistical functions. |
7 |
| -Full details are available in the [docs](https://jstat.github.io/all.html). |
| 4 | +**jStat** provides native javascript implementations of statistical functions. |
| 5 | +Full details are available in the [docs](http://handsontable.github.io/jstat/). |
8 | 6 | jStat provides more functions than most libraries, including the weibull, cauchy, poisson, hypergeometric, and beta distributions.
|
9 | 7 | For most distributions, jStat provides the pdf, cdf, inverse, mean, mode, variance, and a sample function, allowing for more complex calculations.
|
10 | 8 |
|
11 |
| -Using jStat in a Browser |
12 |
| ------------------------- |
13 |
| - |
14 |
| -jStat can be used in the browser. The `jStat` object will be added to the window. For example: |
15 |
| - |
16 |
| -``` |
17 |
| -<script src="components/jstat.js"></script> <!-- include jStat, from the CDN or otherwise --> |
| 9 | +[](https://www.npmjs.com/package/@handsontable/jstat) |
18 | 10 |
|
19 |
| -<script> |
20 |
| -... |
21 |
| -var jstat = this.jStat(dataset); // jStat will be added to the window |
22 |
| -... |
23 |
| -data[i]['cum'] = jstat.normal(jstat.mean(), jstat.stdev()).cdf(data[i].x); |
24 |
| -... |
25 |
| -</script> |
| 11 | +## Table of contents |
26 | 12 |
|
27 |
| -``` |
28 | 13 |
|
29 |
| -CDN |
30 |
| ---- |
| 14 | + 1. [Installation](#installation) |
| 15 | + 2. [Getting Started](#getting-started) |
| 16 | + 3. [Building jStat](#building-jstat) |
| 17 | + 4. [Running Tests](#Running-tests) |
| 18 | + 5. [Get the Code](#get-the-code) |
| 19 | + 6. [Contributing](#contributing) |
| 20 | + 7. [Licensing](#licensing) |
31 | 21 |
|
32 |
| -The library is hosted on [jsDelivr](http://www.jsdelivr.com/) using the follwing |
33 |
| -url: |
| 22 | +## Installation |
| 23 | +Use npm to download the project. |
34 | 24 | ```
|
35 |
| -//cdn.jsdelivr.net/npm/jstat@latest/dist/jstat.min.js |
| 25 | +npm install @handsontable/jstat |
36 | 26 | ```
|
37 |
| -Note that `'latest'` can be replaced with any released verion of jStat. |
38 |
| - |
39 |
| -Module Loaders |
40 |
| --------------- |
41 |
| - |
42 |
| -Currently jStat is exposed as `j$` and `jStat` inside an object, rather than |
43 |
| -exported directly. This may confuse some module loaders, however should be |
44 |
| -easily remedied with the correct configuration. |
45 | 27 |
|
46 |
| -NodeJS & NPM |
47 |
| ------------- |
48 |
| -To install via npm: |
| 28 | +## Getting Started |
49 | 29 |
|
50 |
| -``` |
51 |
| -npm install --save jStat |
52 |
| -``` |
53 |
| - |
54 |
| -When loading under Node be sure to reference the child object. |
| 30 | +jStat can be used in the browser. The `jStat` object will be added to the window. For example: |
55 | 31 |
|
56 |
| -``` |
57 |
| -var jStat = require('jStat').jStat; |
58 |
| -``` |
| 32 | +```html |
| 33 | +<script src="https://cdn.jsdelivr.net/npm/@handsontable/jstat/dist/jstat.min.js"></script> <!-- include jStat, from the CDN or otherwise --> |
| 34 | +<script> |
| 35 | +var jstat = this.jStat(dataset); // jStat will be added to the window |
59 | 36 |
|
60 |
| -RequireJS Shim |
61 |
| --------------- |
| 37 | +data[i]['cum'] = jstat.normal(jstat.mean(), jstat.stdev()).cdf(data[i].x); |
| 38 | +</script> |
62 | 39 |
|
63 |
| -For RequireJS not only `exports` but also `init` function must be specified. |
64 |
| -``` |
65 |
| -requirejs.config({ |
66 |
| - paths: { |
67 |
| - 'jstat': 'path/to/jstat/dist/jstat.min' |
68 |
| - }, |
69 |
| - shim: { |
70 |
| - jstat: { |
71 |
| - exports: ['j$', 'jStat'], |
72 |
| - init: function () { |
73 |
| - return { |
74 |
| - j$: j$, |
75 |
| - jStat: jStat |
76 |
| - }; |
77 |
| - } |
78 |
| - } |
79 |
| - } |
80 |
| -}); |
81 | 40 | ```
|
82 | 41 |
|
83 |
| -Build Prerequisites |
84 |
| -------------------- |
85 |
| - |
86 |
| -In order to build jStat, you need to have GNU make 3.8 or later, Node.js 0.2 or later, and git 1.7 or later. |
87 |
| -(Earlier versions might work OK, but are not tested.) |
88 |
| - |
89 |
| -Windows users have two options: |
90 |
| - |
91 |
| -1. Install [msysgit](https://code.google.com/p/msysgit/) (Full installer for official Git), |
92 |
| - [GNU make for Windows](http://gnuwin32.sourceforge.net/packages/make.htm), and a |
93 |
| - [binary version of Node.js](http://node-js.prcn.co.cc/). Make sure all three packages are installed to the same |
94 |
| - location (by default, this is C:\Program Files\Git). |
95 |
| -2. Install [Cygwin](http://cygwin.com/) (make sure you install the git, make, and which packages), then either follow |
96 |
| - the [Node.js build instructions](https://github.com/ry/node/wiki/Building-node.js-on-Cygwin-%28Windows%29) or install |
97 |
| - the [binary version of Node.js](http://node-js.prcn.co.cc/). |
98 |
| - |
99 |
| -Mac OS users should install Xcode (comes on your Mac OS install DVD, or downloadable from |
100 |
| -[Apple's Xcode site](http://developer.apple.com/technologies/xcode.html)) and |
101 |
| -[http://mxcl.github.com/homebrew/](Homebrew). Once Homebrew is installed, run `brew install git` to install git, |
102 |
| -and `brew install node` to install Node.js. |
| 42 | +Using jStat in Node environment. |
103 | 43 |
|
104 |
| -Linux/BSD users should use their appropriate package managers to install make, git, and node, or build from source |
105 |
| -if you swing that way. |
| 44 | +```js |
| 45 | +const jStat = require('@handsontable/jstat'); |
106 | 46 |
|
| 47 | +data[i]['cum'] = jStat.normal(jStat.mean(), jStat.stdev()).cdf(data[i].x); |
| 48 | +``` |
107 | 49 |
|
108 |
| -Building jStat |
109 |
| --------------- |
| 50 | +## Building jStat |
110 | 51 |
|
111 |
| -First, clone a copy of the jStat git repo by running `git clone git://github.com/jstat/jstat.git`. |
| 52 | +First, clone a copy of the jStat git repo by running `git clone https://github.com/handsontable/jstat.git`. |
112 | 53 |
|
113 |
| -To download all necessary libraries run `npm install`. |
| 54 | +To download all necessary dependencies run `npm install` in the cloned repository. |
114 | 55 |
|
115 |
| -Then, to get a complete, minified version of jStat and all documentation, simply `cd` to the `jstat` directory and |
116 |
| -type `make`. If you don't have Node installed and/or want to make a basic, uncompressed, unlinted version of jstat, |
117 |
| -use `make jstat` instead of `make`. |
| 56 | +Then, to get a complete, minified version of jStat and all documentation, simply type `npm run all`. |
118 | 57 |
|
119 | 58 | The built version of jStat will be put in the `dist/` subdirectory.
|
120 | 59 |
|
121 |
| -Generate just the documentation by running `make doc`. Documentation will be placed in `dist/docs` by default. |
122 |
| - |
123 |
| -To remove all built files, run `make clean`. |
| 60 | +Generate just the documentation by running `npm run doc`. Documentation will be placed in `dist/docs` by default. |
124 | 61 |
|
| 62 | +To remove all built files, run `npm run clean`. |
125 | 63 |
|
126 |
| -Running Tests |
127 |
| -------------- |
| 64 | +## Running Tests |
128 | 65 |
|
129 |
| -Execute all tests by running `make test`. |
| 66 | +Execute all tests by running `npm run test`. |
130 | 67 |
|
131 | 68 | Or if you wish to run a specific test, `cd` to `test/<subdir>` and run `node <some_test>-test.js`.
|
132 | 69 |
|
133 |
| - |
134 |
| -Get the Code |
135 |
| ------------- |
| 70 | +## Get the Code |
136 | 71 |
|
137 | 72 | Both the minified and unminified source are located in the `dist/` directory. For those who don't want to build
|
138 | 73 | it themselves.
|
139 | 74 |
|
| 75 | +## Contributing |
| 76 | +If you would like to help us to develop this library, please first read the [guide for contributors](//github.com/handsontable/jstat/blob/master/CONTRIBUTING.md). |
140 | 77 |
|
141 |
| -Contribute |
142 |
| ----------- |
143 |
| - |
144 |
| -jStat is now going to follow most of the v8 |
145 |
| -[JavaScript](https://google.github.io/styleguide/jsguide.html) |
146 |
| -guidelines. There will be plenty of source that uses the old style, but we're |
147 |
| -going to work away from that. |
148 |
| - |
149 |
| -Also, we'll be going through and reimplementing a good portion of the code to |
150 |
| -run faster. Hopefully it won't take too long to get the project on one basic |
151 |
| -standard. |
152 |
| - |
153 |
| -When submitting pull requests, no need to check in dist/*.js. They'll be recompiled for distribution anyway. |
154 |
| - |
155 |
| -Join the Community |
156 |
| ------------------- |
157 |
| - |
158 |
| -We always like discussion of how to improve jStat. |
159 |
| -Join us at our [mailing list](http://groups.google.com/group/jstat-discuss/) and let us know what you'd like to see. |
160 |
| -Also come ask questions in the #jstat channel on irc.freenode.net. |
| 78 | +## Licensing |
| 79 | +This library is released under the MIT license. |
| 80 | +The project is based on the great work of [jStat](https://github.com/jstat/jstat). |
0 commit comments