extra-math 1.3.32 → 1.3.35
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 +61 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,8 +6,13 @@ A collection of common mathematical functions.<br>
|
|
|
6
6
|
📘 [Wiki](https://github.com/nodef/extra-math/wiki/).
|
|
7
7
|
|
|
8
8
|
Mathematics is the classification and study of all possible patterns [(1)]. This
|
|
9
|
-
package includes common
|
|
10
|
-
*numbers
|
|
9
|
+
package includes common number functions related to querying *about* numbers,
|
|
10
|
+
*comparing* numbers, *rounding* numbers, performing *rounded division*,
|
|
11
|
+
performing *modulo* operations, *controlling range* of numbers, performing
|
|
12
|
+
*arithmetic* operations, obtaining *divisors* of a number (and related
|
|
13
|
+
operations), getting the number of possible *arrangements* of a set of objects,
|
|
14
|
+
performing *geometry*-related calculations, performing basic *statistical*
|
|
15
|
+
analysis, and finding various *statistical means*.
|
|
11
16
|
|
|
12
17
|
**Natural numbers**: There are 3 different ways of performing the *modulo*
|
|
13
18
|
operation: [rem], [mod], and [modp]. [gcd]/`HCF` and [lcm] of a list of numbers
|
|
@@ -17,9 +22,7 @@ can be obtained. To calculate the number of ways of *ordering items*, use
|
|
|
17
22
|
**Real numbers**: *Range* of a number can be controlled with [constrain],
|
|
18
23
|
[normalize], or [remap]. Use [lerp] for *linear interpolation* (or extrapolation);
|
|
19
24
|
[root] for calculating the *n-th root* of a number; and [log] to find the
|
|
20
|
-
*logarithm* of a number with a given base
|
|
21
|
-
functions* (approximations) for a given number can be obtained with [erf]
|
|
22
|
-
and [erfc].
|
|
25
|
+
*logarithm* of a number with a given base..
|
|
23
26
|
|
|
24
27
|
**Geometry**: Perform conversion from [degrees] to [radians] and vice versa.
|
|
25
28
|
Find the [magnitude] of a vector or [distance] between two points.
|
|
@@ -67,23 +70,39 @@ math.lcm(2, 3, 4);
|
|
|
67
70
|
|
|
68
71
|
| Property | Description |
|
|
69
72
|
| ---- | ---- |
|
|
73
|
+
| [floor] | Round down a number to specific precision. |
|
|
74
|
+
| [ceil] | Round up a number to specific precision. |
|
|
75
|
+
| [round] | Round a number to specific precision. |
|
|
76
|
+
| | |
|
|
77
|
+
| [floorDiv] | Perform floor-divison of two numbers. |
|
|
78
|
+
| [ceilDiv] | Perform ceiling-divison of two numbers. |
|
|
79
|
+
| [roundDiv] | Perform rounded-divison of two numbers. |
|
|
80
|
+
| | |
|
|
70
81
|
| [rem] | Find the remainder of x/y with sign of x (truncated division). |
|
|
71
82
|
| [mod] | Find the remainder of x/y with sign of y (floored division). |
|
|
72
83
|
| [modp] | Find the remainder of x/y with +ve sign (euclidean division). |
|
|
73
|
-
| [gcd] | Find the greatest common divisor of numbers. |
|
|
74
|
-
| [lcm] | Find the least common multiple of numbers. |
|
|
75
|
-
| [factorial] | Find the factorial of a number. |
|
|
76
|
-
| [binomial] | Find the number of ways to choose k elements from a set of n elements. |
|
|
77
|
-
| [multinomial] | Find the number of ways to put n objects in m bins (n=sum(kᵢ)). |
|
|
78
84
|
| | |
|
|
79
85
|
| [constrain] | Constrain a number within a minimum and a maximum value. |
|
|
80
86
|
| [normalize] | Normalize a number from its current range into a value between 0 and 1. |
|
|
81
87
|
| [remap] | Re-map a number from one range to another. |
|
|
82
88
|
| [lerp] | Linearly interpolate a number between two numbers. |
|
|
89
|
+
| | |
|
|
90
|
+
| [isPow] | Check if a number is a power-of-n. |
|
|
91
|
+
| [prevPow] | Get previous power-of-n of a number. |
|
|
92
|
+
| [nextPow] | Find next power-of-n of a number. |
|
|
93
|
+
| | |
|
|
83
94
|
| [root] | Find the nth root of a number (ⁿ√). |
|
|
84
95
|
| [log] | Find the logarithm of a number with a given base. |
|
|
85
|
-
|
|
|
86
|
-
| [
|
|
96
|
+
| | |
|
|
97
|
+
| [properDivisors] | List all divisors of a number, except itself. |
|
|
98
|
+
| [aliquotSum] | Sum all proper divisors of a number. |
|
|
99
|
+
| [isPrime] | Check if number is prime. |
|
|
100
|
+
| [gcd] | Find the greatest common divisor of numbers. |
|
|
101
|
+
| [lcm] | Find the least common multiple of numbers. |
|
|
102
|
+
| | |
|
|
103
|
+
| [factorial] | Find the factorial of a number. |
|
|
104
|
+
| [binomial] | Find the number of ways to choose k elements from a set of n elements. |
|
|
105
|
+
| [multinomial] | Find the number of ways to put n objects in m bins (n=sum(kᵢ)). |
|
|
87
106
|
| | |
|
|
88
107
|
| [degrees] | Convert radians to degrees. |
|
|
89
108
|
| [radians] | Convert degrees to radians. |
|
|
@@ -92,11 +111,16 @@ math.lcm(2, 3, 4);
|
|
|
92
111
|
| | |
|
|
93
112
|
| [sum] | Find the sum of numbers (Σ). |
|
|
94
113
|
| [product] | Find the product of numbers (∏). |
|
|
95
|
-
| [mean] | Find the average of numbers. |
|
|
96
114
|
| [median] | Find the value separating the higher and lower halves of numbers. |
|
|
97
115
|
| [modes] | Find the values that appear most often. |
|
|
98
|
-
| [range] | Find the
|
|
116
|
+
| [range] | Find the smallest and largest values. |
|
|
99
117
|
| [variance] | Find the mean of squared deviation of numbers from its mean. |
|
|
118
|
+
| | |
|
|
119
|
+
| [arithmeticMean] | Find the average of numbers. |
|
|
120
|
+
| [geometricMean] | Find the geometric mean of numbers. |
|
|
121
|
+
| [harmonicMean] | Find the harmonic mean of numbers. |
|
|
122
|
+
| [quadriaticMean] | Find the quadriatic mean of numbers. |
|
|
123
|
+
| [cubicMean] | Find the cubic mean of numbers. |
|
|
100
124
|
|
|
101
125
|
<br>
|
|
102
126
|
<br>
|
|
@@ -127,30 +151,44 @@ math.lcm(2, 3, 4);
|
|
|
127
151
|
[](https://codeclimate.com/github/nodef/extra-math/maintainability)
|
|
128
152
|
|
|
129
153
|
|
|
154
|
+
[floor]: https://nodef.github.io/extra-math/functions/floor.html
|
|
155
|
+
[ceil]: https://nodef.github.io/extra-math/functions/ceil.html
|
|
156
|
+
[round]: https://nodef.github.io/extra-math/functions/round.html
|
|
157
|
+
[floorDiv]: https://nodef.github.io/extra-math/functions/floorDiv.html
|
|
158
|
+
[ceilDiv]: https://nodef.github.io/extra-math/functions/ceilDiv.html
|
|
159
|
+
[roundDiv]: https://nodef.github.io/extra-math/functions/roundDiv.html
|
|
130
160
|
[rem]: https://nodef.github.io/extra-math/functions/rem.html
|
|
131
161
|
[mod]: https://nodef.github.io/extra-math/functions/mod.html
|
|
132
162
|
[modp]: https://nodef.github.io/extra-math/functions/modp.html
|
|
163
|
+
[constrain]: https://nodef.github.io/extra-math/functions/constrain.html
|
|
164
|
+
[normalize]: https://nodef.github.io/extra-math/functions/normalize.html
|
|
165
|
+
[remap]: https://nodef.github.io/extra-math/functions/remap.html
|
|
166
|
+
[lerp]: https://nodef.github.io/extra-math/functions/lerp.html
|
|
167
|
+
[isPow]: https://nodef.github.io/extra-math/functions/isPow.html
|
|
168
|
+
[prevPow]: https://nodef.github.io/extra-math/functions/prevPow.html
|
|
169
|
+
[nextPow]: https://nodef.github.io/extra-math/functions/nextPow.html
|
|
170
|
+
[root]: https://nodef.github.io/extra-math/functions/root.html
|
|
171
|
+
[log]: https://nodef.github.io/extra-math/functions/log.html
|
|
172
|
+
[properDivisors]: https://nodef.github.io/extra-math/functions/properDivisors.html
|
|
173
|
+
[aliquotSum]: https://nodef.github.io/extra-math/functions/aliquotSum.html
|
|
174
|
+
[isPrime]: https://nodef.github.io/extra-math/functions/isPrime.html
|
|
133
175
|
[gcd]: https://nodef.github.io/extra-math/functions/gcd.html
|
|
134
176
|
[lcm]: https://nodef.github.io/extra-math/functions/lcm.html
|
|
135
177
|
[factorial]: https://nodef.github.io/extra-math/functions/factorial.html
|
|
136
178
|
[binomial]: https://nodef.github.io/extra-math/functions/binomial.html
|
|
137
179
|
[multinomial]: https://nodef.github.io/extra-math/functions/multinomial.html
|
|
138
|
-
[constrain]: https://nodef.github.io/extra-math/functions/constrain.html
|
|
139
|
-
[root]: https://nodef.github.io/extra-math/functions/root.html
|
|
140
|
-
[log]: https://nodef.github.io/extra-math/functions/log.html
|
|
141
|
-
[normalize]: https://nodef.github.io/extra-math/functions/normalize.html
|
|
142
|
-
[remap]: https://nodef.github.io/extra-math/functions/remap.html
|
|
143
|
-
[lerp]: https://nodef.github.io/extra-math/functions/lerp.html
|
|
144
|
-
[erf]: https://nodef.github.io/extra-math/functions/erf.html
|
|
145
|
-
[erfc]: https://nodef.github.io/extra-math/functions/erfc.html
|
|
146
180
|
[degrees]: https://nodef.github.io/extra-math/functions/degrees.html
|
|
147
181
|
[radians]: https://nodef.github.io/extra-math/functions/radians.html
|
|
148
182
|
[magnitude]: https://nodef.github.io/extra-math/functions/magnitude.html
|
|
149
183
|
[distance]: https://nodef.github.io/extra-math/functions/distance.html
|
|
150
184
|
[sum]: https://nodef.github.io/extra-math/functions/sum.html
|
|
151
185
|
[product]: https://nodef.github.io/extra-math/functions/product.html
|
|
152
|
-
[mean]: https://nodef.github.io/extra-math/functions/mean.html
|
|
153
186
|
[median]: https://nodef.github.io/extra-math/functions/median.html
|
|
154
187
|
[modes]: https://nodef.github.io/extra-math/functions/modes.html
|
|
155
188
|
[range]: https://nodef.github.io/extra-math/functions/range.html
|
|
156
189
|
[variance]: https://nodef.github.io/extra-math/functions/variance.html
|
|
190
|
+
[arithmeticMean]: https://nodef.github.io/extra-math/functions/arithmeticMean.html
|
|
191
|
+
[geometricMean]: https://nodef.github.io/extra-math/functions/geometricMean.html
|
|
192
|
+
[harmonicMean]: https://nodef.github.io/extra-math/functions/harmonicMean.html
|
|
193
|
+
[quadriaticMean]: https://nodef.github.io/extra-math/functions/quadriaticMean.html
|
|
194
|
+
[cubicMean]: https://nodef.github.io/extra-math/functions/cubicMean.html
|