Skip to content

Commit abd015e

Browse files
committed
project setup
1 parent f1a829a commit abd015e

11 files changed

+728
-2
lines changed

Diff for: Gruntfile.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = function (grunt) {
2+
// Load the plugin that provides the "uglify" task.
3+
grunt.loadNpmTasks('grunt-contrib-uglify');
4+
grunt.loadNpmTasks('grunt-mocha-test');
5+
grunt.loadNpmTasks('grunt-eslint');
6+
7+
grunt.initConfig({
8+
pkg: grunt.file.readJSON('package.json'),
9+
uglify: {
10+
options: {
11+
preserveComments: 'some',
12+
},
13+
build: {
14+
src: 'src/jssort.js',
15+
dest: 'build/jssort.min.js',
16+
},
17+
},
18+
mochaTest: {
19+
test: {
20+
options: {
21+
reporter: 'spec',
22+
},
23+
src: ['tests/**/*.js'],
24+
},
25+
},
26+
});
27+
28+
// Default task(s).
29+
grunt.registerTask('default', ['uglify']);
30+
grunt.registerTask('test', ['mochaTest']);
31+
};

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Xianshun Chen
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+90-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,90 @@
1-
# js-sorting-algorithms
2-
Package provides javascript of array sorting algorithms
1+
# js-sort
2+
Package provides the implementation of various statistics distribution such as normal distribution, fisher, student-t, and so on
3+
4+
[![Build Status](https://travis-ci.org/cschen1205/js-sort.svg?branch=master)](https://travis-ci.org/cschen1205/js-sort) [![Coverage Status](https://coveralls.io/repos/github/cschen1205/js-sort/badge.svg?branch=master)](https://coveralls.io/github/cschen1205/js-sort?branch=master)
5+
6+
# Features
7+
8+
* Normal Distribution
9+
10+
- cumulativeProbability(Z)
11+
- invCumulativeProbability(p)
12+
13+
* Student's T Distribution
14+
15+
- cumulativeProbability(t_df)
16+
- invCumulativeProbability(p)
17+
18+
* Fisher–Snedecor Distribution
19+
20+
- cumulativeProbabiliyt(F)
21+
22+
* Chi-Square Distribution
23+
24+
- cumulativeProbabiliy(ChiSquare)
25+
26+
# Install
27+
28+
Run the following npm command to install
29+
30+
```bash
31+
npm install js-sort
32+
```
33+
34+
# Usage
35+
36+
Sample code is available at [playground](https://runkit.com/cschen1205/js-sort-playground)
37+
38+
### Using with nodejs
39+
40+
```javascript
41+
jssort = require('js-sort');
42+
43+
//====================NORMAL DISTRIBUTION====================//
44+
45+
var mu = 0.0; // mean
46+
var sd = 1.0; // standard deviation
47+
var normal_distribution = new jssort.NormalDistribution(mu, sd);
48+
49+
var X = 10.0; // point estimate value
50+
var p = normal_distribution.cumulativeProbability(X); // cumulative probability
51+
52+
var p = 0.7; // cumulative probability
53+
var X = normal_distribution.invCumulativeProbability(p); // point estimate value
54+
55+
//====================T DISTRIBUTION====================//
56+
57+
var df = 10; // degrees of freedom for t-distribution
58+
var t_distribution = new jssort.TDistribution(df);
59+
60+
var t_df = 10.0; // point estimate or test statistic
61+
var p = t_distribution.cumulativeProbability(t_df); // cumulative probability
62+
63+
var p = 0.7;
64+
var t_df = t_distribution.invCumulativeProbability(p); // point estimate or test statistic
65+
66+
67+
//====================F DISTRIBUTION====================//
68+
69+
var df1 = 10; // degrees of freedom for f-distribution
70+
var df2 = 20; // degrees of freedom for f-distribution
71+
var f_distribution = new jssort.FDistribution(df1, df2);
72+
73+
var F = 10.0; // point estimate or test statistic
74+
var p = f_distribution.cumulativeProbability(F); // cumulative probability
75+
76+
77+
//====================Chi Square DISTRIBUTION====================//
78+
79+
var df = 10; // degrees of freedom for cs-distribution
80+
var cs_distribution = new jssort.ChiSquareDistribution(df);
81+
82+
var X = 10.0; // point estimate or test statistic
83+
var p = cs_distribution.cumulativeProbability(X); // cumulative probability
84+
85+
86+
87+
```
88+
89+
### Using with HTML page
90+

Diff for: build/jsstats.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./src/jssort');

Diff for: package.json

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "js-sorting-algorithms",
3+
"version": "1.0.0",
4+
"description": "Package implements various array sorting algorithms",
5+
"author": "Caishun Chen",
6+
"contributors": [
7+
"Caishun Chen <[email protected]>"
8+
],
9+
"license": "MIT",
10+
"main": "index.js",
11+
"directories": {
12+
"test": "test"
13+
},
14+
"scripts": {
15+
"test": "mocha test",
16+
"cover": "istanbul cover _mocha",
17+
"coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"
18+
},
19+
"bin": {
20+
"js-sort": "./src/jssort.js"
21+
},
22+
"repository": {
23+
"type": "git",
24+
"url": "git+https://github.com/cschen1205/js-sorting-algorithms.git"
25+
},
26+
"keywords": [
27+
"merge sort",
28+
"quick sort",
29+
"3 ways quick sort",
30+
"insertion sort",
31+
"selection sort",
32+
"shell sort",
33+
"heap sort",
34+
"array sorting",
35+
"sorting algorthms"
36+
],
37+
"dependencies": {
38+
39+
},
40+
"devDependencies": {
41+
"chai": "^3.5.0",
42+
"coveralls": "^2.13.1",
43+
"grunt": "^1.0.1",
44+
"grunt-contrib-uglify": "^3.0.0",
45+
"grunt-eslint": "^19.0.0",
46+
"grunt-mocha-test": "^0.13.2",
47+
"istanbul": "^0.4.5",
48+
"mocha": "^3.4.1"
49+
},
50+
"bugs": {
51+
"url": "https://github.com/cschen1205/js-sorting-algorithms/issues"
52+
},
53+
"homepage": "https://github.com/cschen1205/js-sorting-algorithms#readme"
54+
}

0 commit comments

Comments
 (0)