smath 1.13.0 → 1.13.2
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/dist/index.js +3 -1
- package/package.json +3 -3
- package/types/index.d.ts +13 -13
package/dist/index.js
CHANGED
|
@@ -231,7 +231,9 @@ function factors(n) {
|
|
|
231
231
|
* ```
|
|
232
232
|
*/
|
|
233
233
|
function round2(n, base) {
|
|
234
|
-
|
|
234
|
+
var rounded = base ? base * Math.round(n / base) : n;
|
|
235
|
+
var precision = 10; // Removes precision errors
|
|
236
|
+
return parseFloat(rounded.toFixed(precision));
|
|
235
237
|
}
|
|
236
238
|
/**
|
|
237
239
|
* Calculate the relative normalized error or deviation from any
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smath",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.2",
|
|
4
4
|
"description": "Small math function library",
|
|
5
5
|
"homepage": "https://npm.nicfv.com/",
|
|
6
6
|
"bin": "dist/bin.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"repository": "github:nicfv/npm",
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@types/node": "24.0
|
|
56
|
-
"t6": "1.2.
|
|
55
|
+
"@types/node": "24.3.0",
|
|
56
|
+
"t6": "1.2.1"
|
|
57
57
|
}
|
|
58
58
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export declare function translate(n: number, min1: number, max1: number, min2: n
|
|
|
82
82
|
* // [ 1, 1.8, 2.6, 3.4, 4.2, 5 ]
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
|
-
export declare function linspace(min: number, max: number, count: number):
|
|
85
|
+
export declare function linspace(min: number, max: number, count: number): number[];
|
|
86
86
|
/**
|
|
87
87
|
* Generate an array of logarithmically spaced numbers.
|
|
88
88
|
* @param min The initial magnitude of the space
|
|
@@ -95,7 +95,7 @@ export declare function linspace(min: number, max: number, count: number): Array
|
|
|
95
95
|
* // [ 1, 3.2, 10, 31.6, 100 ]
|
|
96
96
|
* ```
|
|
97
97
|
*/
|
|
98
|
-
export declare function logspace(min: number, max: number, count: number):
|
|
98
|
+
export declare function logspace(min: number, max: number, count: number): number[];
|
|
99
99
|
/**
|
|
100
100
|
* Compute the factorial of `n`.
|
|
101
101
|
* @param n Any positive integer
|
|
@@ -115,7 +115,7 @@ export declare function factorial(n: number): number;
|
|
|
115
115
|
* const y = SMath.factors(12); // [ 2, 2, 3 ]
|
|
116
116
|
* ```
|
|
117
117
|
*/
|
|
118
|
-
export declare function factors(n: number):
|
|
118
|
+
export declare function factors(n: number): number[];
|
|
119
119
|
/**
|
|
120
120
|
* Round a number to the nearest multiple of an arbitrary
|
|
121
121
|
* base. Does not round when the base is set to zero.
|
|
@@ -154,7 +154,7 @@ export declare function error(experimental: number, actual: number): number;
|
|
|
154
154
|
* const y = SMath.sum([1, 2, 3]); // 6
|
|
155
155
|
* ```
|
|
156
156
|
*/
|
|
157
|
-
export declare function sum(data:
|
|
157
|
+
export declare function sum(data: number[]): number;
|
|
158
158
|
/**
|
|
159
159
|
* Multiply all the inputs.
|
|
160
160
|
* If none are present, returns 1.
|
|
@@ -165,7 +165,7 @@ export declare function sum(data: Array<number>): number;
|
|
|
165
165
|
* const y = SMath.prod([2, 2, 3, 5]); // 60
|
|
166
166
|
* ```
|
|
167
167
|
*/
|
|
168
|
-
export declare function prod(data:
|
|
168
|
+
export declare function prod(data: number[]): number;
|
|
169
169
|
/**
|
|
170
170
|
* Compute the average, or mean, of a set of numbers.
|
|
171
171
|
* @param data An array of numeric inputs
|
|
@@ -175,7 +175,7 @@ export declare function prod(data: Array<number>): number;
|
|
|
175
175
|
* const y = SMath.avg([1, 2, 4, 4]); // 2.75
|
|
176
176
|
* ```
|
|
177
177
|
*/
|
|
178
|
-
export declare function avg(data:
|
|
178
|
+
export declare function avg(data: number[]): number;
|
|
179
179
|
/**
|
|
180
180
|
* Compute the median of a set of numbers.
|
|
181
181
|
* @param data An array of numeric inputs
|
|
@@ -185,7 +185,7 @@ export declare function avg(data: Array<number>): number;
|
|
|
185
185
|
* const y = SMath.median([2, 5, 3, 1]); // 2.5
|
|
186
186
|
* ```
|
|
187
187
|
*/
|
|
188
|
-
export declare function median(data:
|
|
188
|
+
export declare function median(data: number[]): number;
|
|
189
189
|
/**
|
|
190
190
|
* Compute the variance of a **complete population**.
|
|
191
191
|
* @param data An array of numeric inputs
|
|
@@ -195,7 +195,7 @@ export declare function median(data: Array<number>): number;
|
|
|
195
195
|
* const y = SMath.varp([1, 2, 4, 4]); // 1.6875
|
|
196
196
|
* ```
|
|
197
197
|
*/
|
|
198
|
-
export declare function varp(data:
|
|
198
|
+
export declare function varp(data: number[]): number;
|
|
199
199
|
/**
|
|
200
200
|
* Compute the variance of a **sample**.
|
|
201
201
|
* @param data An array of numeric inputs
|
|
@@ -205,7 +205,7 @@ export declare function varp(data: Array<number>): number;
|
|
|
205
205
|
* const y = SMath.vars([1, 2, 4, 4]); // 2.25
|
|
206
206
|
* ```
|
|
207
207
|
*/
|
|
208
|
-
export declare function vars(data:
|
|
208
|
+
export declare function vars(data: number[]): number;
|
|
209
209
|
/**
|
|
210
210
|
* Compute the standard deviation of a **complete population**.
|
|
211
211
|
* @param data An array of numeric inputs
|
|
@@ -215,7 +215,7 @@ export declare function vars(data: Array<number>): number;
|
|
|
215
215
|
* const y = SMath.stdevp([1, 2, 3, 4]); // 1.118...
|
|
216
216
|
* ```
|
|
217
217
|
*/
|
|
218
|
-
export declare function stdevp(data:
|
|
218
|
+
export declare function stdevp(data: number[]): number;
|
|
219
219
|
/**
|
|
220
220
|
* Compute the standard deviation of a **sample**.
|
|
221
221
|
* @param data An array of numeric inputs
|
|
@@ -225,7 +225,7 @@ export declare function stdevp(data: Array<number>): number;
|
|
|
225
225
|
* const y = SMath.stdevs([1, 2, 3, 4]); // 1.29...
|
|
226
226
|
* ```
|
|
227
227
|
*/
|
|
228
|
-
export declare function stdevs(data:
|
|
228
|
+
export declare function stdevs(data: number[]): number;
|
|
229
229
|
/**
|
|
230
230
|
* Generate a uniformly-distributed floating-point number within the range.
|
|
231
231
|
* @param min The minimum bound
|
|
@@ -270,7 +270,7 @@ export declare function rnorm(mean?: number, stdev?: number): number;
|
|
|
270
270
|
* const dataset = SMath.rdist(3); // [ 1.051..., -0.779..., -2.254... ]
|
|
271
271
|
* ```
|
|
272
272
|
*/
|
|
273
|
-
export declare function rdist(count: number, mean?: number, stdev?: number):
|
|
273
|
+
export declare function rdist(count: number, mean?: number, stdev?: number): number[];
|
|
274
274
|
/**
|
|
275
275
|
* Randomize an array of arbitrary elements.
|
|
276
276
|
* @param stack An array of arbitrary elements
|
|
@@ -280,7 +280,7 @@ export declare function rdist(count: number, mean?: number, stdev?: number): Arr
|
|
|
280
280
|
* const shuffled = SMath.shuffle(['a', 'b', 'c']); // [ 'c', 'a', 'b' ]
|
|
281
281
|
* ```
|
|
282
282
|
*/
|
|
283
|
-
export declare function shuffle<T>(stack:
|
|
283
|
+
export declare function shuffle<T>(stack: T[]): T[];
|
|
284
284
|
/**
|
|
285
285
|
* Take the limit of a function. A return value of `NaN` indicates
|
|
286
286
|
* that no limit exists either due to a discontinuity or imaginary value.
|