@@ -5,82 +5,56 @@ Package provides the implementation of various statistics distribution such as n
5
5
6
6
# Features
7
7
8
- * Normal Distribution
9
-
10
- - cumulativeProbability(Z)
11
- - invCumulativeProbability(p)
8
+ In terms of usage, the user has the following benefit of using the sorting algorithms:
12
9
13
- * Student's T Distribution
10
+ * Customizable comparer function for the sorting function
11
+ * Allow user to sort a sublist of an array starting and ending at the user-defined indices
14
12
15
- - cumulativeProbability(t_df)
16
- - invCumulativeProbability(p)
13
+ In terms of supported algorithms for sorting:
17
14
18
- * Fisher–Snedecor Distribution
19
-
20
- - cumulativeProbabiliyt(F)
21
-
22
- * Chi-Square Distribution
23
-
24
- - cumulativeProbabiliy(ChiSquare)
15
+ * Selection Sort
16
+ * Insertion Sort
17
+ * Merge Sort
18
+ * Quick Sort
19
+ * 3-Ways Quick Sort
20
+ * Heap Sort
21
+ * Shell Sort
25
22
26
23
# Install
27
24
28
25
Run the following npm command to install
29
26
30
27
``` bash
31
- npm install js-sort
28
+ npm install js-sorting-algorithms
32
29
```
33
30
34
31
# Usage
35
32
36
- Sample code is available at [ playground] ( https://runkit.com/cschen1205/js-sort -playground )
33
+ Sample code is available at [ playground] ( https://runkit.com/cschen1205/js-sorting-algorithms -playground )
37
34
38
35
### Using with nodejs
39
36
40
37
``` javascript
41
38
jssort = require (' js-sort' );
42
39
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
40
+ // ====================Simple====================//
75
41
42
+ var a = [3 , 4 , 5 , 1 , 2 , 4 , 6 , 8 , 9 , 3 , 4 , 67 , 34 , 53 , 44 , 2 ];
43
+ jssort .insertionSort (a);
44
+ console .log (a);
76
45
77
- // ====================Chi Square DISTRIBUTION====================//
46
+ // ====================Sort with custom comparer function====================//
47
+ var a = [[3 , 2.3 ], [4 , 3.1 ], [5 , 1.1 ], [1 , 4.2 ], [2 , 4.2 ], [4 , 5.3 ], [6 , 7.4 ], [8 , 5.1 ], [9 , 1.9 ], [3 , 1.2 ], [4 , 3.4 ], [67 , 6.7 ], [34 , 3 ], [53 , 5 ], [44 , 4.2 ], [2 , 0 ]];
48
+ jssort .insertionSort (a, undefined , undefined , function (a1 , a2 ){
49
+ return a1[1 ] - a2[1 ];
50
+ });
51
+ console .log (a);
78
52
79
- var df = 10 ; // degrees of freedom for cs-distribution
80
- var cs_distribution = new jssort.ChiSquareDistribution (df);
81
53
82
- var X = 10.0 ; // point estimate or test statistic
83
- var p = cs_distribution .cumulativeProbability (X ); // cumulative probability
54
+ // ====================Sort sub-arrray a[3:10] ====================//
55
+ var a = [3 , 4 , 5 , 1 , 2 , 4 , 6 , 8 , 9 , 3 , 4 , 67 , 34 , 53 , 44 , 2 ];
56
+ jssort .insertionSort (a, 3 , 10 );
57
+ console .log (a);
84
58
85
59
86
60
0 commit comments