extra-math 1.2.4 โ†’ 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,10 @@
1
1
  Mathematics is the classification and study of all possible patterns.
2
2
  This package includes some common statistics functions. [(1)]<br>
3
- :package: [NPM](https://www.npmjs.com/package/extra-math),
4
- :smiley_cat: [GitHub](https://github.com/orgs/nodef/packages?repo_name=extra-math),
5
- :running: [RunKit](https://npm.runkit.com/extra-math),
6
- :vhs: [Asciinema](https://asciinema.org/a/337174),
7
- :moon: [Minified](https://www.npmjs.com/package/extra-math.min),
8
- :scroll: [Files](https://unpkg.com/extra-math/),
9
- :newspaper: [JSDoc](https://nodef.github.io/extra-math/),
10
- :blue_book: [Wiki](https://github.com/nodef/extra-math/wiki/).
3
+ ๐Ÿ“ฆ [Node.js](https://www.npmjs.com/package/extra-math),
4
+ ๐ŸŒ [Web](https://www.npmjs.com/package/extra-math.web),
5
+ ๐Ÿ“œ [Files](https://unpkg.com/extra-math/),
6
+ ๐Ÿ“ฐ [JSDoc](https://nodef.github.io/extra-math/),
7
+ ๐Ÿ“˜ [Wiki](https://github.com/nodef/extra-math/wiki/).
11
8
 
12
9
  > Stability: Experimental.
13
10
 
package/index.d.ts CHANGED
@@ -2,50 +2,57 @@
2
2
  * Find the remainder of x/y with sign of x (truncated division).
3
3
  * @param x dividend
4
4
  * @param y divisor
5
+ * @returns trunc(x/y)
5
6
  */
6
7
  declare function rem(x: number, y: number): number;
7
8
  /**
8
9
  * Find the remainder of x/y with sign of y (floored division).
9
10
  * @param x dividend
10
11
  * @param y divisor
12
+ * @returns floor(x/y)
11
13
  */
12
14
  declare function mod(x: number, y: number): number;
13
15
  /**
14
16
  * Find the remainder of x/y with +ve sign (euclidean division).
15
17
  * @param x dividend
16
18
  * @param y divisor
19
+ * @returns n>0: floor(x/y), n<0: ceil(x/y)
17
20
  */
18
21
  declare function modp(x: number, y: number): number;
19
22
  /**
20
23
  * Find the greatest common divisor of numbers.
21
24
  * @param xs a list of numbers
25
+ * @returns gcd(xโ‚, xโ‚‚, ...)
22
26
  */
23
27
  declare function gcd(...xs: number[]): number;
24
28
  /**
25
29
  * Find the least common multiple of numbers.
26
30
  * @param xs a list of numbers
31
+ * @returns lcm(xโ‚, xโ‚‚, ...)
27
32
  */
28
33
  declare function lcm(...xs: number[]): number;
29
34
  /**
30
35
  * Find the factorial of a number.
31
- * @param x a number
36
+ * @param n a number
32
37
  * @param k denominator factorial [0]
33
- * @returns k=0: x!, x!/k!
38
+ * @returns P(n, k); k=0: n!, k>0: n!/k!
34
39
  */
35
- declare function factorial(x: number, k?: number): number;
40
+ declare function factorial(n: number, k?: number): number;
36
41
  /**
37
42
  * Find the number of ways to choose k elements from a set of n elements.
38
43
  * @param n elements in source set
39
44
  * @param k elements in choose set
45
+ * @returns C(n, k)
40
46
  */
41
47
  declare function binomial(n: number, k: number): number;
42
48
  /**
43
- * TODO: Find the number of ways to put n objects in m bins (n=sum(ki)).
44
- * @param k objects per bin (ki)
49
+ * Find the number of ways to put n objects in m bins (n=sum(kแตข)).
50
+ * @param ks objects per bin (kแตข)
51
+ * @returns n!/(kโ‚!kโ‚‚!...)
45
52
  */
46
- declare function multinomial(...k: number[]): number;
53
+ declare function multinomial(...ks: number[]): number;
47
54
  /**
48
- * Constrain a number within a minimum and maximum value.
55
+ * Constrain a number within a minimum and a maximum value.
49
56
  * @param x a number
50
57
  * @param min minimum value
51
58
  * @param max maximum value
@@ -60,7 +67,7 @@ declare function constrain(x: number, min: number, max: number): number;
60
67
  */
61
68
  declare function root(x: number, n: number): number;
62
69
  /**
63
- * TODO: (log?) Find the logarithm of a number with a given base.
70
+ * Find the logarithm of a number with a given base.
64
71
  * @param x a number
65
72
  * @param b logarithm base
66
73
  * @returns log_b (x)
package/index.js CHANGED
@@ -28,11 +28,11 @@ function gcd(...xs) {
28
28
  function lcm(...xs) {
29
29
  return product(...xs) / gcd(...xs);
30
30
  }
31
- function factorial(x, k = 0) {
32
- if (x < 0)
31
+ function factorial(n, k = 0) {
32
+ if (n < 0)
33
33
  return 0;
34
- for (var i = k + 1, a = 1; i <= x; i++)
35
- a *= x;
34
+ for (var i = k + 1, a = 1; i <= n; i++)
35
+ a *= n;
36
36
  return a;
37
37
  }
38
38
  function binomial(n, k) {
@@ -45,11 +45,11 @@ function binomial(n, k) {
45
45
  a *= n / i;
46
46
  return a;
47
47
  }
48
- function multinomial(...k) {
49
- var n = sum(...k), a = 1;
50
- for (var i = 0, j = 0, I = k.length; i < I;) {
48
+ function multinomial(...ks) {
49
+ var n = sum(...ks), a = 1;
50
+ for (var i = 0, j = 0, I = ks.length; i < I;) {
51
51
  if (j <= 0)
52
- j = k[i++];
52
+ j = ks[i++];
53
53
  else
54
54
  a *= n-- / j--;
55
55
  }
package/index.mjs CHANGED
@@ -24,11 +24,11 @@ function gcd(...xs) {
24
24
  function lcm(...xs) {
25
25
  return product(...xs) / gcd(...xs);
26
26
  }
27
- function factorial(x, k = 0) {
28
- if (x < 0)
27
+ function factorial(n, k = 0) {
28
+ if (n < 0)
29
29
  return 0;
30
- for (var i = k + 1, a = 1; i <= x; i++)
31
- a *= x;
30
+ for (var i = k + 1, a = 1; i <= n; i++)
31
+ a *= n;
32
32
  return a;
33
33
  }
34
34
  function binomial(n, k) {
@@ -41,11 +41,11 @@ function binomial(n, k) {
41
41
  a *= n / i;
42
42
  return a;
43
43
  }
44
- function multinomial(...k) {
45
- var n = sum(...k), a = 1;
46
- for (var i = 0, j = 0, I = k.length; i < I;) {
44
+ function multinomial(...ks) {
45
+ var n = sum(...ks), a = 1;
46
+ for (var i = 0, j = 0, I = ks.length; i < I;) {
47
47
  if (j <= 0)
48
- j = k[i++];
48
+ j = ks[i++];
49
49
  else
50
50
  a *= n-- / j--;
51
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-math",
3
- "version": "1.2.4",
3
+ "version": "1.2.7",
4
4
  "description": "Mathematics is the classification and study of all possible patterns.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",