@numio/bigmath 2.3.1 → 2.3.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/CHANGELOG.md +18 -15
- package/package.json +1 -1
- package/src/FDR/fdr.js +2 -2
- package/src/FDR/types.d.ts +2 -2
- package/src/FDR/utils.js +8 -8
package/CHANGELOG.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
### 2.3.2
|
2
|
+
FDR - change variable name to make it consistent
|
3
|
+
|
1
4
|
### 2.3.1
|
2
5
|
Fix import
|
3
6
|
|
4
7
|
### 2.2.8
|
5
|
-
Better error handling
|
6
|
-
Add FDR - Freedman-Diaconis Rule
|
8
|
+
Better error handling \
|
9
|
+
Add FDR - Freedman-Diaconis Rule \
|
7
10
|
MAD - median of the absolute deviations from `median` or `mean`
|
8
11
|
|
9
12
|
### 2.2.7
|
@@ -13,48 +16,48 @@ Throw an error if input is not valid. In the error show exact invalid input.
|
|
13
16
|
Optimize performance for small numbers (add operation)
|
14
17
|
|
15
18
|
### 2.2.5
|
16
|
-
Handle "0B", "0X", "0O", "-0B", "-0X", "-0O" as a start of the input for toBase function.
|
19
|
+
Handle "0B", "0X", "0O", "-0B", "-0X", "-0O" as a start of the input for toBase function. \
|
17
20
|
Move documentation from README.md to web-site http://numio.deno.dev
|
18
21
|
|
19
22
|
### 2.2.4
|
20
23
|
Fix handling negative numbers for toBase function.
|
21
24
|
|
22
25
|
### 2.2.3
|
23
|
-
Add validation for negative number input in square root function
|
26
|
+
Add validation for negative number input in square root function \
|
24
27
|
Add validation for negative number input in cube root function
|
25
28
|
|
26
29
|
### 2.2.2
|
27
|
-
Throw an error if input for MAD and IQR is less than 3 elements
|
30
|
+
Throw an error if input for MAD and IQR is less than 3 elements \
|
28
31
|
Add home-page url
|
29
32
|
|
30
33
|
### 2.2.1
|
31
34
|
Add Number format validation examples (README.md)
|
32
35
|
|
33
36
|
### 2.2.0
|
34
|
-
Added `isHex(str: string): boolean` - Checks if a string is a valid hexadecimal number (prefixed with `0x` or `-0x`).
|
35
|
-
Added `isBinary(str: string): boolean` - Checks if a string is a valid binary number (prefixed with `0b` or `-0b`).
|
36
|
-
Added `isDecimal(str: string): boolean` - Checks if a string is a valid decimal number.
|
37
|
-
Added `isOctal(str: string): boolean` - Checks if a string is a valid octal number (prefixed with `0o` or `-0o`).
|
37
|
+
Added `isHex(str: string): boolean` - Checks if a string is a valid hexadecimal number (prefixed with `0x` or `-0x`). \
|
38
|
+
Added `isBinary(str: string): boolean` - Checks if a string is a valid binary number (prefixed with `0b` or `-0b`). \
|
39
|
+
Added `isDecimal(str: string): boolean` - Checks if a string is a valid decimal number. \
|
40
|
+
Added `isOctal(str: string): boolean` - Checks if a string is a valid octal number (prefixed with `0o` or `-0o`). \
|
38
41
|
Added `isNumber(str: string): boolean` - Checks if a string is a valid number in any of the formats supported by the library (decimal, hexadecimal, binary, octal).
|
39
42
|
|
40
43
|
### 2.1.3
|
41
44
|
Optimize performance for small numbers
|
42
45
|
|
43
46
|
### 2.1.2
|
44
|
-
Renamed main.ts files
|
45
|
-
Changed import path in test files
|
47
|
+
Renamed main.ts files \
|
48
|
+
Changed import path in test files \
|
46
49
|
Change build config - run test on JSR and NPM versions
|
47
50
|
|
48
51
|
### 2.1.1
|
49
52
|
Fixed lib crash (NPM version)
|
50
53
|
|
51
54
|
### 2.1.0
|
52
|
-
Added `toBase` - convert number to another base
|
53
|
-
Added `abs` - absolute value
|
54
|
-
Added `isLeftGreaterOrEqual` - Is the left-hand side value greater than or equal to the right-hand side value
|
55
|
+
Added `toBase` - convert number to another base \
|
56
|
+
Added `abs` - absolute value \
|
57
|
+
Added `isLeftGreaterOrEqual` - Is the left-hand side value greater \ than or equal to the right-hand side value \
|
55
58
|
Added `cbrt` - cube root of a number
|
56
59
|
|
57
|
-
Added `Pipe().abs` - absolute value in pipe
|
60
|
+
Added `Pipe().abs` - absolute value in pipe \
|
58
61
|
Added `Pipe().resultToBase` - convert number to another base in pipe
|
59
62
|
|
60
63
|
### 2.0.0
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@numio/bigmath",
|
3
3
|
"description": "@numio/bigmath is an arbitrary-precision arithmetic library. It can be used for basic operations with decimal numbers (integers and float)",
|
4
|
-
"version": "2.3.
|
4
|
+
"version": "2.3.2",
|
5
5
|
"keywords": [
|
6
6
|
"precision",
|
7
7
|
"arithmetic",
|
package/src/FDR/fdr.js
CHANGED
@@ -6,13 +6,13 @@ export const FDR = (array, options) => {
|
|
6
6
|
for (let i = 0; i < array.length; i++) {
|
7
7
|
arrayInner[i] = s2bi(array[i]);
|
8
8
|
}
|
9
|
-
const { binWidth,
|
9
|
+
const { binWidth, binNum } = fdrInner(arrayInner, {
|
10
10
|
useMadAbove: (_a = options === null || options === void 0 ? void 0 : options.useMadAbove) !== null && _a !== void 0 ? _a : 0,
|
11
11
|
maxBinNumber: (_b = options === null || options === void 0 ? void 0 : options.maxBinNumber) !== null && _b !== void 0 ? _b : 90,
|
12
12
|
madFrom: (_c = options === null || options === void 0 ? void 0 : options.madFrom) !== null && _c !== void 0 ? _c : "median",
|
13
13
|
});
|
14
14
|
return {
|
15
|
-
|
15
|
+
binNum: bi2s(binNum),
|
16
16
|
binWidth: bi2s(binWidth),
|
17
17
|
};
|
18
18
|
};
|
package/src/FDR/types.d.ts
CHANGED
@@ -12,10 +12,10 @@ type OptionsInner = {
|
|
12
12
|
};
|
13
13
|
export type FDRInner = (array: BI[], options: OptionsInner) => {
|
14
14
|
binWidth: BI;
|
15
|
-
|
15
|
+
binNum: BI;
|
16
16
|
};
|
17
17
|
export type TFDR = (array: string[], options?: Options) => {
|
18
18
|
binWidth: string;
|
19
|
-
|
19
|
+
binNum: string;
|
20
20
|
};
|
21
21
|
export {};
|
package/src/FDR/utils.js
CHANGED
@@ -6,11 +6,11 @@ import { divInner } from "../operations/div/utils.js";
|
|
6
6
|
import { PipeInner } from "../pipe/utils.js";
|
7
7
|
import { tryBigInt } from "../shared/utils.js";
|
8
8
|
const getBinsNum = (range, binWidth) => {
|
9
|
-
let
|
10
|
-
if (
|
11
|
-
|
9
|
+
let binNum = new PipeInner().div([range, binWidth], 10).bi;
|
10
|
+
if (binNum[1] > 0) {
|
11
|
+
binNum = [new PipeInner().div([range, binWidth], 0).bi[0] + 1n, 0];
|
12
12
|
}
|
13
|
-
return
|
13
|
+
return binNum;
|
14
14
|
};
|
15
15
|
export const fdrInner = (array, options = { useMadAbove: 0, maxBinNumber: 90, madFrom: "mean" }) => {
|
16
16
|
const mad = MADInner(array, { from: options.madFrom });
|
@@ -21,14 +21,14 @@ export const fdrInner = (array, options = { useMadAbove: 0, maxBinNumber: 90, ma
|
|
21
21
|
const [cbrtLen] = cbrtInner([tryBigInt(array.length), 0]);
|
22
22
|
const binWidth = new PipeInner().mul([[2n, 0], validIQR]).div([cbrtLen]).bi;
|
23
23
|
const range = new PipeInner().sub([array[array.length - 1], array[0]]).bi;
|
24
|
-
const
|
24
|
+
const binNum = getBinsNum(range, binWidth);
|
25
25
|
const maxBinNum = [tryBigInt(options.maxBinNumber), 0];
|
26
|
-
const scale = isLeftGreaterOrEqualInner({ left:
|
27
|
-
? divInner([
|
26
|
+
const scale = isLeftGreaterOrEqualInner({ left: binNum, right: maxBinNum })
|
27
|
+
? divInner([binNum, maxBinNum], 20)
|
28
28
|
: [1n, 0];
|
29
29
|
const scaledBinWidth = new PipeInner().mul([binWidth, scale]).bi;
|
30
30
|
return {
|
31
31
|
binWidth: scaledBinWidth,
|
32
|
-
|
32
|
+
binNum: getBinsNum(range, scaledBinWidth),
|
33
33
|
};
|
34
34
|
};
|