@thi.ng/fuzzy 2.1.2 → 2.1.5
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 +1 -1
- package/README.md +1 -1
- package/defuzz.d.ts +7 -7
- package/defuzz.js +7 -7
- package/package.json +19 -19
- package/rules.d.ts +3 -3
- package/rules.js +3 -3
- package/shapes.d.ts +34 -34
- package/shapes.js +34 -34
- package/strategies/bisector.d.ts +1 -1
- package/strategies/bisector.js +1 -1
- package/strategies/centroid.d.ts +1 -1
- package/strategies/centroid.js +1 -1
- package/strategies/maxima.d.ts +3 -3
- package/strategies/maxima.js +3 -3
- package/tnorms.d.ts +11 -11
- package/tnorms.js +11 -11
- package/var.d.ts +7 -7
- package/var.js +7 -7
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/defuzz.d.ts
CHANGED
|
@@ -17,13 +17,13 @@ import type { LVarSet, Rule } from "./api.js";
|
|
|
17
17
|
* relevant output sets of all rules for integration/analysis by the given
|
|
18
18
|
* defuzz `strategy` actually producing the crisp result.
|
|
19
19
|
*
|
|
20
|
-
* @param ins
|
|
21
|
-
* @param outs
|
|
22
|
-
* @param rules
|
|
23
|
-
* @param vals
|
|
24
|
-
* @param strategy
|
|
25
|
-
* @param imply
|
|
26
|
-
* @param combine
|
|
20
|
+
* @param ins -
|
|
21
|
+
* @param outs -
|
|
22
|
+
* @param rules -
|
|
23
|
+
* @param vals -
|
|
24
|
+
* @param strategy -
|
|
25
|
+
* @param imply -
|
|
26
|
+
* @param combine -
|
|
27
27
|
*/
|
|
28
28
|
export declare const defuzz: <I extends LVarSet<string>, O extends LVarSet<string>>(ins: I, outs: O, rules: Rule<I, O>[], vals: Partial<Record<keyof I, number>>, strategy?: import("./api.js").DefuzzStrategy, imply?: import("@thi.ng/api").FnN2, combine?: import("@thi.ng/api").FnN2) => Partial<Record<keyof O, number>>;
|
|
29
29
|
//# sourceMappingURL=defuzz.d.ts.map
|
package/defuzz.js
CHANGED
|
@@ -19,13 +19,13 @@ import { snormMax, tnormMin } from "./tnorms.js";
|
|
|
19
19
|
* relevant output sets of all rules for integration/analysis by the given
|
|
20
20
|
* defuzz `strategy` actually producing the crisp result.
|
|
21
21
|
*
|
|
22
|
-
* @param ins
|
|
23
|
-
* @param outs
|
|
24
|
-
* @param rules
|
|
25
|
-
* @param vals
|
|
26
|
-
* @param strategy
|
|
27
|
-
* @param imply
|
|
28
|
-
* @param combine
|
|
22
|
+
* @param ins -
|
|
23
|
+
* @param outs -
|
|
24
|
+
* @param rules -
|
|
25
|
+
* @param vals -
|
|
26
|
+
* @param strategy -
|
|
27
|
+
* @param imply -
|
|
28
|
+
* @param combine -
|
|
29
29
|
*/
|
|
30
30
|
export const defuzz = (ins, outs, rules, vals, strategy = centroidStrategy(), imply = tnormMin, combine = snormMax) => {
|
|
31
31
|
const ruleTerms = rules.map((r) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/fuzzy",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "Fuzzy logic operators & configurable rule inferencing engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.3.
|
|
38
|
-
"@thi.ng/math": "^5.1
|
|
37
|
+
"@thi.ng/api": "^8.3.5",
|
|
38
|
+
"@thi.ng/math": "^5.3.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@microsoft/api-extractor": "^7.
|
|
42
|
-
"@thi.ng/testament": "^0.2.
|
|
41
|
+
"@microsoft/api-extractor": "^7.19.4",
|
|
42
|
+
"@thi.ng/testament": "^0.2.5",
|
|
43
43
|
"rimraf": "^3.0.2",
|
|
44
44
|
"tools": "^0.0.1",
|
|
45
|
-
"typedoc": "^0.22.
|
|
46
|
-
"typescript": "^4.
|
|
45
|
+
"typedoc": "^0.22.13",
|
|
46
|
+
"typescript": "^4.6.2"
|
|
47
47
|
},
|
|
48
48
|
"keywords": [
|
|
49
49
|
"agent",
|
|
@@ -69,41 +69,41 @@
|
|
|
69
69
|
],
|
|
70
70
|
"exports": {
|
|
71
71
|
".": {
|
|
72
|
-
"
|
|
72
|
+
"default": "./index.js"
|
|
73
73
|
},
|
|
74
74
|
"./api": {
|
|
75
|
-
"
|
|
75
|
+
"default": "./api.js"
|
|
76
76
|
},
|
|
77
77
|
"./defuzz": {
|
|
78
|
-
"
|
|
78
|
+
"default": "./defuzz.js"
|
|
79
79
|
},
|
|
80
80
|
"./rules": {
|
|
81
|
-
"
|
|
81
|
+
"default": "./rules.js"
|
|
82
82
|
},
|
|
83
83
|
"./shapes": {
|
|
84
|
-
"
|
|
84
|
+
"default": "./shapes.js"
|
|
85
85
|
},
|
|
86
86
|
"./strategies/bisector": {
|
|
87
|
-
"
|
|
87
|
+
"default": "./strategies/bisector.js"
|
|
88
88
|
},
|
|
89
89
|
"./strategies/centroid": {
|
|
90
|
-
"
|
|
90
|
+
"default": "./strategies/centroid.js"
|
|
91
91
|
},
|
|
92
92
|
"./strategies/maxima": {
|
|
93
|
-
"
|
|
93
|
+
"default": "./strategies/maxima.js"
|
|
94
94
|
},
|
|
95
95
|
"./strategies/opts": {
|
|
96
|
-
"
|
|
96
|
+
"default": "./strategies/opts.js"
|
|
97
97
|
},
|
|
98
98
|
"./tnorms": {
|
|
99
|
-
"
|
|
99
|
+
"default": "./tnorms.js"
|
|
100
100
|
},
|
|
101
101
|
"./var": {
|
|
102
|
-
"
|
|
102
|
+
"default": "./var.js"
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
105
|
"thi.ng": {
|
|
106
106
|
"year": 2020
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "5ee1feb590dd935593b1dd4e7f38a3ed3ba64765\n"
|
|
109
109
|
}
|
package/rules.d.ts
CHANGED
|
@@ -29,10 +29,10 @@ import type { LVarKeySet, LVarSet, Rule } from "./api.js";
|
|
|
29
29
|
* )
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
|
-
* @param op
|
|
32
|
+
* @param op -
|
|
33
33
|
* @param $if
|
|
34
|
-
* @param then
|
|
35
|
-
* @param weight
|
|
34
|
+
* @param then -
|
|
35
|
+
* @param weight -
|
|
36
36
|
*/
|
|
37
37
|
export declare const rule: <I extends LVarSet<string>, O extends LVarSet<string>>(op: FnN2, $if: Partial<{ [k in keyof I]: keyof I[k]["terms"]; }>, then: Partial<{ [k_1 in keyof O]: keyof O[k_1]["terms"]; }>, weight?: number) => Rule<I, O>;
|
|
38
38
|
export declare const and: <I extends LVarSet<string>, O extends LVarSet<string>>($if: Partial<{ [k in keyof I]: keyof I[k]["terms"]; }>, then: Partial<{ [k_1 in keyof O]: keyof O[k_1]["terms"]; }>, weight?: number | undefined) => Rule<I, O>;
|
package/rules.js
CHANGED
|
@@ -28,10 +28,10 @@ import { snormMax, tnormMin, tnormProduct } from "./tnorms.js";
|
|
|
28
28
|
* )
|
|
29
29
|
* ```
|
|
30
30
|
*
|
|
31
|
-
* @param op
|
|
31
|
+
* @param op -
|
|
32
32
|
* @param $if
|
|
33
|
-
* @param then
|
|
34
|
-
* @param weight
|
|
33
|
+
* @param then -
|
|
34
|
+
* @param weight -
|
|
35
35
|
*/
|
|
36
36
|
export const rule = (op, $if, then, weight = 1) => ({
|
|
37
37
|
if: $if,
|
package/shapes.d.ts
CHANGED
|
@@ -4,23 +4,23 @@ import type { FuzzyFn } from "./api.js";
|
|
|
4
4
|
* HOF {@link FuzzyFn} always yielding given `x` (should be in [0,1]
|
|
5
5
|
* interval).
|
|
6
6
|
*
|
|
7
|
-
* @param x
|
|
7
|
+
* @param x -
|
|
8
8
|
*/
|
|
9
9
|
export declare const constant: (x: number) => FuzzyFn;
|
|
10
10
|
/**
|
|
11
11
|
* HOF {@link FuzzyFn} which takes a value `p` and tolerance `eps`, then yields
|
|
12
12
|
* a discrete window function: `|p - x| <= eps ? 1 : 0`
|
|
13
13
|
*
|
|
14
|
-
* @param p
|
|
15
|
-
* @param eps
|
|
14
|
+
* @param p -
|
|
15
|
+
* @param eps -
|
|
16
16
|
*/
|
|
17
17
|
export declare const point: (p: number, eps?: number) => FuzzyFn;
|
|
18
18
|
/**
|
|
19
19
|
* HOF {@link FuzzyFn} yielding a rising ramp in [a,b] interval, clamped to
|
|
20
20
|
* [0,1] outputs. Returns 0.0 for inputs <= `a` and 1.0 for inputs >= `b`.
|
|
21
21
|
*
|
|
22
|
-
* @param a
|
|
23
|
-
* @param b
|
|
22
|
+
* @param a -
|
|
23
|
+
* @param b -
|
|
24
24
|
*/
|
|
25
25
|
export declare const ramp: FnU2<number, FuzzyFn>;
|
|
26
26
|
/**
|
|
@@ -28,9 +28,9 @@ export declare const ramp: FnU2<number, FuzzyFn>;
|
|
|
28
28
|
* `b` defining the position of the peak value (1.0). Returns 0.0 for inputs <
|
|
29
29
|
* `a` or > `c`.
|
|
30
30
|
*
|
|
31
|
-
* @param a
|
|
32
|
-
* @param b
|
|
33
|
-
* @param c
|
|
31
|
+
* @param a -
|
|
32
|
+
* @param b -
|
|
33
|
+
* @param c -
|
|
34
34
|
*/
|
|
35
35
|
export declare const triangle: FnU3<number, FuzzyFn>;
|
|
36
36
|
/**
|
|
@@ -38,71 +38,71 @@ export declare const triangle: FnU3<number, FuzzyFn>;
|
|
|
38
38
|
* `[a..b..c..d]` with `b` and `c` defining the peak value range (with 1.0
|
|
39
39
|
* outputs). Returns 0.0 for inputs < `a` or > `d`.
|
|
40
40
|
*
|
|
41
|
-
* @param a
|
|
42
|
-
* @param b
|
|
43
|
-
* @param c
|
|
44
|
-
* @param d
|
|
41
|
+
* @param a -
|
|
42
|
+
* @param b -
|
|
43
|
+
* @param c -
|
|
44
|
+
* @param d -
|
|
45
45
|
*/
|
|
46
46
|
export declare const trapezoid: FnU4<number, FuzzyFn>;
|
|
47
47
|
/**
|
|
48
48
|
* HOF {@link FuzzyFn}, yielding sigmoid curve with configurable `steep` and
|
|
49
49
|
* positioned such that `f(bias) = 0.5`.
|
|
50
50
|
*
|
|
51
|
-
* @param bias
|
|
52
|
-
* @param steep
|
|
51
|
+
* @param bias -
|
|
52
|
+
* @param steep -
|
|
53
53
|
*/
|
|
54
54
|
export declare const sigmoid: FnU2<number, FuzzyFn>;
|
|
55
55
|
/**
|
|
56
56
|
* HOF {@link FuzzyFn}, yielding gaussian bell curve with its peak at `bias` and
|
|
57
57
|
* width defined by `sigma`.
|
|
58
58
|
*
|
|
59
|
-
* @param bias
|
|
60
|
-
* @param sigma
|
|
59
|
+
* @param bias -
|
|
60
|
+
* @param sigma -
|
|
61
61
|
*/
|
|
62
62
|
export declare const gaussian: FnU2<number, FuzzyFn>;
|
|
63
63
|
/**
|
|
64
64
|
* Higher-order function: Takes an existing {@link FuzzyFn} `fn` and returns
|
|
65
65
|
* a new one producing its negated outcome aka `1 - fn(x)`.
|
|
66
66
|
*
|
|
67
|
-
* @param fn
|
|
67
|
+
* @param fn -
|
|
68
68
|
*/
|
|
69
69
|
export declare const negate: FnU<FuzzyFn>;
|
|
70
70
|
/**
|
|
71
71
|
* Inverse of {@link ramp}, i.e. a falling slope from `a` -> `b`.
|
|
72
72
|
*
|
|
73
|
-
* @param a
|
|
74
|
-
* @param b
|
|
73
|
+
* @param a -
|
|
74
|
+
* @param b -
|
|
75
75
|
*/
|
|
76
76
|
export declare const invRamp: FnU2<number, FuzzyFn>;
|
|
77
77
|
/**
|
|
78
78
|
* Inverse of {@link sigmoid}.
|
|
79
79
|
*
|
|
80
|
-
* @param bias
|
|
81
|
-
* @param steep
|
|
80
|
+
* @param bias -
|
|
81
|
+
* @param steep -
|
|
82
82
|
*/
|
|
83
83
|
export declare const invSigmoid: FnU2<number, FuzzyFn>;
|
|
84
84
|
/**
|
|
85
85
|
* Higher-order function: Takes an existing {@link FuzzyFn} `fn` and `weight`
|
|
86
86
|
* factor. Returns new function which computes: `weight * fn(x)`.
|
|
87
87
|
*
|
|
88
|
-
* @param fn
|
|
89
|
-
* @param weight
|
|
88
|
+
* @param fn -
|
|
89
|
+
* @param weight -
|
|
90
90
|
*/
|
|
91
91
|
export declare const weighted: (fn: FuzzyFn, weight: number) => FuzzyFn;
|
|
92
92
|
/**
|
|
93
93
|
* Higher order function. Returns new function which selects subset of given
|
|
94
94
|
* fuzzy set where `fn(x) > alpha`, or else returns 0.
|
|
95
95
|
*
|
|
96
|
-
* @param fn
|
|
97
|
-
* @param alpha
|
|
96
|
+
* @param fn -
|
|
97
|
+
* @param alpha -
|
|
98
98
|
*/
|
|
99
99
|
export declare const alphaCut: (fn: FuzzyFn, alpha?: number) => FuzzyFn;
|
|
100
100
|
/**
|
|
101
101
|
* Higher order function. Returns new function which selects subset of given
|
|
102
102
|
* fuzzy set where `fn(x) < alpha`, or else returns 0.
|
|
103
103
|
*
|
|
104
|
-
* @param fn
|
|
105
|
-
* @param alpha
|
|
104
|
+
* @param fn -
|
|
105
|
+
* @param alpha -
|
|
106
106
|
*/
|
|
107
107
|
export declare const invAlphaCut: (fn: FuzzyFn, alpha?: number) => FuzzyFn;
|
|
108
108
|
/**
|
|
@@ -147,25 +147,25 @@ export declare const invAlphaCut: (fn: FuzzyFn, alpha?: number) => FuzzyFn;
|
|
|
147
147
|
* M(5) // 1
|
|
148
148
|
* ```
|
|
149
149
|
*
|
|
150
|
-
* @param op
|
|
151
|
-
* @param initial
|
|
152
|
-
* @param fns
|
|
150
|
+
* @param op -
|
|
151
|
+
* @param initial -
|
|
152
|
+
* @param fns -
|
|
153
153
|
*/
|
|
154
154
|
export declare const compose: (op: FnN2, initial: number, ...fns: FuzzyFn[]) => FuzzyFn;
|
|
155
155
|
/**
|
|
156
156
|
* Syntax sugar for {@link compose} with an initial value of 1.0. The `op` is
|
|
157
157
|
* supposed to be a T-norm.
|
|
158
158
|
*
|
|
159
|
-
* @param op
|
|
160
|
-
* @param fns
|
|
159
|
+
* @param op -
|
|
160
|
+
* @param fns -
|
|
161
161
|
*/
|
|
162
162
|
export declare const intersect: (op: FnN2, ...fns: FuzzyFn[]) => import("@thi.ng/api").FnN;
|
|
163
163
|
/**
|
|
164
164
|
* Syntax sugar for {@link compose} with an initial value of 0.0. The `op` is
|
|
165
165
|
* supposed to be a S-norm.
|
|
166
166
|
*
|
|
167
|
-
* @param op
|
|
168
|
-
* @param fns
|
|
167
|
+
* @param op -
|
|
168
|
+
* @param fns -
|
|
169
169
|
*/
|
|
170
170
|
export declare const union: (op: FnN2, ...fns: FuzzyFn[]) => import("@thi.ng/api").FnN;
|
|
171
171
|
//# sourceMappingURL=shapes.d.ts.map
|
package/shapes.js
CHANGED
|
@@ -6,23 +6,23 @@ import { gaussian as $gaussian, sigmoid as $sigmoid } from "@thi.ng/math/mix";
|
|
|
6
6
|
* HOF {@link FuzzyFn} always yielding given `x` (should be in [0,1]
|
|
7
7
|
* interval).
|
|
8
8
|
*
|
|
9
|
-
* @param x
|
|
9
|
+
* @param x -
|
|
10
10
|
*/
|
|
11
11
|
export const constant = (x) => () => x;
|
|
12
12
|
/**
|
|
13
13
|
* HOF {@link FuzzyFn} which takes a value `p` and tolerance `eps`, then yields
|
|
14
14
|
* a discrete window function: `|p - x| <= eps ? 1 : 0`
|
|
15
15
|
*
|
|
16
|
-
* @param p
|
|
17
|
-
* @param eps
|
|
16
|
+
* @param p -
|
|
17
|
+
* @param eps -
|
|
18
18
|
*/
|
|
19
19
|
export const point = (p, eps = EPS) => (x) => eqDelta(x, p, eps) ? 1 : 0;
|
|
20
20
|
/**
|
|
21
21
|
* HOF {@link FuzzyFn} yielding a rising ramp in [a,b] interval, clamped to
|
|
22
22
|
* [0,1] outputs. Returns 0.0 for inputs <= `a` and 1.0 for inputs >= `b`.
|
|
23
23
|
*
|
|
24
|
-
* @param a
|
|
25
|
-
* @param b
|
|
24
|
+
* @param a -
|
|
25
|
+
* @param b -
|
|
26
26
|
*/
|
|
27
27
|
export const ramp = (a, b) => (x) => fitClamped(x, a, b, 0, 1);
|
|
28
28
|
/**
|
|
@@ -30,9 +30,9 @@ export const ramp = (a, b) => (x) => fitClamped(x, a, b, 0, 1);
|
|
|
30
30
|
* `b` defining the position of the peak value (1.0). Returns 0.0 for inputs <
|
|
31
31
|
* `a` or > `c`.
|
|
32
32
|
*
|
|
33
|
-
* @param a
|
|
34
|
-
* @param b
|
|
35
|
-
* @param c
|
|
33
|
+
* @param a -
|
|
34
|
+
* @param b -
|
|
35
|
+
* @param c -
|
|
36
36
|
*/
|
|
37
37
|
export const triangle = (a, b, c) => (x) => x < a || x > c ? 0 : x <= b ? fit(x, a, b, 0, 1) : fit(x, b, c, 1, 0);
|
|
38
38
|
/**
|
|
@@ -40,10 +40,10 @@ export const triangle = (a, b, c) => (x) => x < a || x > c ? 0 : x <= b ? fit(x,
|
|
|
40
40
|
* `[a..b..c..d]` with `b` and `c` defining the peak value range (with 1.0
|
|
41
41
|
* outputs). Returns 0.0 for inputs < `a` or > `d`.
|
|
42
42
|
*
|
|
43
|
-
* @param a
|
|
44
|
-
* @param b
|
|
45
|
-
* @param c
|
|
46
|
-
* @param d
|
|
43
|
+
* @param a -
|
|
44
|
+
* @param b -
|
|
45
|
+
* @param c -
|
|
46
|
+
* @param d -
|
|
47
47
|
*/
|
|
48
48
|
export const trapezoid = (a, b, c, d) => (x) => x < a || x > d
|
|
49
49
|
? 0
|
|
@@ -56,53 +56,53 @@ export const trapezoid = (a, b, c, d) => (x) => x < a || x > d
|
|
|
56
56
|
* HOF {@link FuzzyFn}, yielding sigmoid curve with configurable `steep` and
|
|
57
57
|
* positioned such that `f(bias) = 0.5`.
|
|
58
58
|
*
|
|
59
|
-
* @param bias
|
|
60
|
-
* @param steep
|
|
59
|
+
* @param bias -
|
|
60
|
+
* @param steep -
|
|
61
61
|
*/
|
|
62
62
|
export const sigmoid = (bias, steep) => (x) => $sigmoid(bias, steep, x);
|
|
63
63
|
/**
|
|
64
64
|
* HOF {@link FuzzyFn}, yielding gaussian bell curve with its peak at `bias` and
|
|
65
65
|
* width defined by `sigma`.
|
|
66
66
|
*
|
|
67
|
-
* @param bias
|
|
68
|
-
* @param sigma
|
|
67
|
+
* @param bias -
|
|
68
|
+
* @param sigma -
|
|
69
69
|
*/
|
|
70
70
|
export const gaussian = (bias, sigma) => (x) => $gaussian(bias, sigma, x);
|
|
71
71
|
/**
|
|
72
72
|
* Higher-order function: Takes an existing {@link FuzzyFn} `fn` and returns
|
|
73
73
|
* a new one producing its negated outcome aka `1 - fn(x)`.
|
|
74
74
|
*
|
|
75
|
-
* @param fn
|
|
75
|
+
* @param fn -
|
|
76
76
|
*/
|
|
77
77
|
export const negate = (fn) => (x) => 1 - fn(x);
|
|
78
78
|
/**
|
|
79
79
|
* Inverse of {@link ramp}, i.e. a falling slope from `a` -> `b`.
|
|
80
80
|
*
|
|
81
|
-
* @param a
|
|
82
|
-
* @param b
|
|
81
|
+
* @param a -
|
|
82
|
+
* @param b -
|
|
83
83
|
*/
|
|
84
84
|
export const invRamp = (a, b) => negate(ramp(a, b));
|
|
85
85
|
/**
|
|
86
86
|
* Inverse of {@link sigmoid}.
|
|
87
87
|
*
|
|
88
|
-
* @param bias
|
|
89
|
-
* @param steep
|
|
88
|
+
* @param bias -
|
|
89
|
+
* @param steep -
|
|
90
90
|
*/
|
|
91
91
|
export const invSigmoid = (bias, steep) => negate(sigmoid(bias, steep));
|
|
92
92
|
/**
|
|
93
93
|
* Higher-order function: Takes an existing {@link FuzzyFn} `fn` and `weight`
|
|
94
94
|
* factor. Returns new function which computes: `weight * fn(x)`.
|
|
95
95
|
*
|
|
96
|
-
* @param fn
|
|
97
|
-
* @param weight
|
|
96
|
+
* @param fn -
|
|
97
|
+
* @param weight -
|
|
98
98
|
*/
|
|
99
99
|
export const weighted = (fn, weight) => (x) => weight * fn(x);
|
|
100
100
|
/**
|
|
101
101
|
* Higher order function. Returns new function which selects subset of given
|
|
102
102
|
* fuzzy set where `fn(x) > alpha`, or else returns 0.
|
|
103
103
|
*
|
|
104
|
-
* @param fn
|
|
105
|
-
* @param alpha
|
|
104
|
+
* @param fn -
|
|
105
|
+
* @param alpha -
|
|
106
106
|
*/
|
|
107
107
|
export const alphaCut = (fn, alpha = 0.5) => (x) => {
|
|
108
108
|
const y = fn(x);
|
|
@@ -112,8 +112,8 @@ export const alphaCut = (fn, alpha = 0.5) => (x) => {
|
|
|
112
112
|
* Higher order function. Returns new function which selects subset of given
|
|
113
113
|
* fuzzy set where `fn(x) < alpha`, or else returns 0.
|
|
114
114
|
*
|
|
115
|
-
* @param fn
|
|
116
|
-
* @param alpha
|
|
115
|
+
* @param fn -
|
|
116
|
+
* @param alpha -
|
|
117
117
|
*/
|
|
118
118
|
export const invAlphaCut = (fn, alpha = 0.5) => (x) => {
|
|
119
119
|
const y = fn(x);
|
|
@@ -161,9 +161,9 @@ export const invAlphaCut = (fn, alpha = 0.5) => (x) => {
|
|
|
161
161
|
* M(5) // 1
|
|
162
162
|
* ```
|
|
163
163
|
*
|
|
164
|
-
* @param op
|
|
165
|
-
* @param initial
|
|
166
|
-
* @param fns
|
|
164
|
+
* @param op -
|
|
165
|
+
* @param initial -
|
|
166
|
+
* @param fns -
|
|
167
167
|
*/
|
|
168
168
|
export const compose = (op, initial, ...fns) => {
|
|
169
169
|
const [a, b] = fns;
|
|
@@ -182,15 +182,15 @@ export const compose = (op, initial, ...fns) => {
|
|
|
182
182
|
* Syntax sugar for {@link compose} with an initial value of 1.0. The `op` is
|
|
183
183
|
* supposed to be a T-norm.
|
|
184
184
|
*
|
|
185
|
-
* @param op
|
|
186
|
-
* @param fns
|
|
185
|
+
* @param op -
|
|
186
|
+
* @param fns -
|
|
187
187
|
*/
|
|
188
188
|
export const intersect = (op, ...fns) => compose(op, 1, ...fns);
|
|
189
189
|
/**
|
|
190
190
|
* Syntax sugar for {@link compose} with an initial value of 0.0. The `op` is
|
|
191
191
|
* supposed to be a S-norm.
|
|
192
192
|
*
|
|
193
|
-
* @param op
|
|
194
|
-
* @param fns
|
|
193
|
+
* @param op -
|
|
194
|
+
* @param fns -
|
|
195
195
|
*/
|
|
196
196
|
export const union = (op, ...fns) => compose(op, 0, ...fns);
|
package/strategies/bisector.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ import type { DefuzzStrategy, DefuzzStrategyOpts } from "../api.js";
|
|
|
27
27
|
* // ^ 2.97
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
-
* @param opts
|
|
30
|
+
* @param opts -
|
|
31
31
|
*/
|
|
32
32
|
export declare const bisectorStrategy: (opts?: Partial<DefuzzStrategyOpts> | undefined) => DefuzzStrategy;
|
|
33
33
|
//# sourceMappingURL=bisector.d.ts.map
|
package/strategies/bisector.js
CHANGED
package/strategies/centroid.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ import type { DefuzzStrategy, DefuzzStrategyOpts } from "../api.js";
|
|
|
27
27
|
* // ^ 3.00
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
-
* @param opts
|
|
30
|
+
* @param opts -
|
|
31
31
|
*/
|
|
32
32
|
export declare const centroidStrategy: (opts?: Partial<DefuzzStrategyOpts> | undefined) => DefuzzStrategy;
|
|
33
33
|
//# sourceMappingURL=centroid.d.ts.map
|
package/strategies/centroid.js
CHANGED
package/strategies/maxima.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ import type { DefuzzStrategy, DefuzzStrategyOpts } from "../api.js";
|
|
|
24
24
|
* // ^ 3.00
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
27
|
-
* @param opts
|
|
27
|
+
* @param opts -
|
|
28
28
|
*/
|
|
29
29
|
export declare const meanOfMaximaStrategy: (opts?: Partial<DefuzzStrategyOpts> | undefined) => DefuzzStrategy;
|
|
30
30
|
/**
|
|
@@ -53,7 +53,7 @@ export declare const meanOfMaximaStrategy: (opts?: Partial<DefuzzStrategyOpts> |
|
|
|
53
53
|
* // ^ 1.02
|
|
54
54
|
* ```
|
|
55
55
|
*
|
|
56
|
-
* @param opts
|
|
56
|
+
* @param opts -
|
|
57
57
|
*/
|
|
58
58
|
export declare const firstOfMaximaStrategy: (opts?: Partial<DefuzzStrategyOpts> | undefined) => DefuzzStrategy;
|
|
59
59
|
/**
|
|
@@ -82,7 +82,7 @@ export declare const firstOfMaximaStrategy: (opts?: Partial<DefuzzStrategyOpts>
|
|
|
82
82
|
* // ^ 4.98
|
|
83
83
|
* ```
|
|
84
84
|
*
|
|
85
|
-
* @param opts
|
|
85
|
+
* @param opts -
|
|
86
86
|
*/
|
|
87
87
|
export declare const lastOfMaximaStrategy: (opts?: Partial<DefuzzStrategyOpts> | undefined) => DefuzzStrategy;
|
|
88
88
|
//# sourceMappingURL=maxima.d.ts.map
|
package/strategies/maxima.js
CHANGED
|
@@ -25,7 +25,7 @@ import { defaultOpts } from "./opts.js";
|
|
|
25
25
|
* // ^ 3.00
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
|
-
* @param opts
|
|
28
|
+
* @param opts -
|
|
29
29
|
*/
|
|
30
30
|
export const meanOfMaximaStrategy = (opts) => {
|
|
31
31
|
const { samples, eps } = defaultOpts(opts);
|
|
@@ -76,7 +76,7 @@ export const meanOfMaximaStrategy = (opts) => {
|
|
|
76
76
|
* // ^ 1.02
|
|
77
77
|
* ```
|
|
78
78
|
*
|
|
79
|
-
* @param opts
|
|
79
|
+
* @param opts -
|
|
80
80
|
*/
|
|
81
81
|
export const firstOfMaximaStrategy = (opts) => {
|
|
82
82
|
const { samples } = defaultOpts(opts);
|
|
@@ -121,7 +121,7 @@ export const firstOfMaximaStrategy = (opts) => {
|
|
|
121
121
|
* // ^ 4.98
|
|
122
122
|
* ```
|
|
123
123
|
*
|
|
124
|
-
* @param opts
|
|
124
|
+
* @param opts -
|
|
125
125
|
*/
|
|
126
126
|
export const lastOfMaximaStrategy = (opts) => {
|
|
127
127
|
const impl = firstOfMaximaStrategy(opts);
|
package/tnorms.d.ts
CHANGED
|
@@ -43,23 +43,23 @@ export declare const tnormAczelAlsina: (p?: number) => FnN2;
|
|
|
43
43
|
/**
|
|
44
44
|
* S-norm (T-conorm), dual of {@link tnormMin}.
|
|
45
45
|
*
|
|
46
|
-
* @param x
|
|
47
|
-
* @param y
|
|
46
|
+
* @param x -
|
|
47
|
+
* @param y -
|
|
48
48
|
*/
|
|
49
49
|
export declare const snormMax: FnN2;
|
|
50
50
|
/**
|
|
51
51
|
* S-norm (T-conorm), dual of {@link tnormProduct}, probabilistic sum:
|
|
52
52
|
* `a + b - a * b`
|
|
53
53
|
*
|
|
54
|
-
* @param x
|
|
55
|
-
* @param y
|
|
54
|
+
* @param x -
|
|
55
|
+
* @param y -
|
|
56
56
|
*/
|
|
57
57
|
export declare const snormProbabilistic: FnN2;
|
|
58
58
|
/**
|
|
59
59
|
* S-norm (T-conorm), dual of {@link tnormLukasiewicz}.
|
|
60
60
|
*
|
|
61
|
-
* @param x
|
|
62
|
-
* @param y
|
|
61
|
+
* @param x -
|
|
62
|
+
* @param y -
|
|
63
63
|
*/
|
|
64
64
|
export declare const snormBoundedSum: FnN2;
|
|
65
65
|
/**
|
|
@@ -69,16 +69,16 @@ export declare const snormDrastic: FnN2;
|
|
|
69
69
|
/**
|
|
70
70
|
* S-norm (T-conorm), dual of {@link tnormNilpotent}.
|
|
71
71
|
*
|
|
72
|
-
* @param x
|
|
73
|
-
* @param y
|
|
72
|
+
* @param x -
|
|
73
|
+
* @param y -
|
|
74
74
|
*/
|
|
75
75
|
export declare const snormNilpotent: FnN2;
|
|
76
76
|
/**
|
|
77
77
|
* S-norm (T-conorm), dual of {@link tnormHamacher}, iff that T-norm's curve
|
|
78
78
|
* param is `p=2`.
|
|
79
79
|
*
|
|
80
|
-
* @param x
|
|
81
|
-
* @param y
|
|
80
|
+
* @param x -
|
|
81
|
+
* @param y -
|
|
82
82
|
*/
|
|
83
83
|
export declare const snormEinstein: FnN2;
|
|
84
84
|
/**
|
|
@@ -88,7 +88,7 @@ export declare const snormEinstein: FnN2;
|
|
|
88
88
|
* @remarks
|
|
89
89
|
* Reference: https://en.wikipedia.org/wiki/Construction_of_t-norms#Ordinal_sums
|
|
90
90
|
*
|
|
91
|
-
* @param specs
|
|
91
|
+
* @param specs -
|
|
92
92
|
*/
|
|
93
93
|
export declare const ordinalSum: (specs: {
|
|
94
94
|
domain: Range;
|
package/tnorms.js
CHANGED
|
@@ -53,23 +53,23 @@ export const tnormAczelAlsina = (p = 2) => (x, y) => Math.exp(-((Math.abs(Math.l
|
|
|
53
53
|
/**
|
|
54
54
|
* S-norm (T-conorm), dual of {@link tnormMin}.
|
|
55
55
|
*
|
|
56
|
-
* @param x
|
|
57
|
-
* @param y
|
|
56
|
+
* @param x -
|
|
57
|
+
* @param y -
|
|
58
58
|
*/
|
|
59
59
|
export const snormMax = (x, y) => Math.max(x, y);
|
|
60
60
|
/**
|
|
61
61
|
* S-norm (T-conorm), dual of {@link tnormProduct}, probabilistic sum:
|
|
62
62
|
* `a + b - a * b`
|
|
63
63
|
*
|
|
64
|
-
* @param x
|
|
65
|
-
* @param y
|
|
64
|
+
* @param x -
|
|
65
|
+
* @param y -
|
|
66
66
|
*/
|
|
67
67
|
export const snormProbabilistic = (x, y) => x + y - x * y;
|
|
68
68
|
/**
|
|
69
69
|
* S-norm (T-conorm), dual of {@link tnormLukasiewicz}.
|
|
70
70
|
*
|
|
71
|
-
* @param x
|
|
72
|
-
* @param y
|
|
71
|
+
* @param x -
|
|
72
|
+
* @param y -
|
|
73
73
|
*/
|
|
74
74
|
export const snormBoundedSum = (x, y) => Math.min(x + y, 1);
|
|
75
75
|
/**
|
|
@@ -79,16 +79,16 @@ export const snormDrastic = (x, y) => (x === 0 ? y : y === 0 ? x : 1);
|
|
|
79
79
|
/**
|
|
80
80
|
* S-norm (T-conorm), dual of {@link tnormNilpotent}.
|
|
81
81
|
*
|
|
82
|
-
* @param x
|
|
83
|
-
* @param y
|
|
82
|
+
* @param x -
|
|
83
|
+
* @param y -
|
|
84
84
|
*/
|
|
85
85
|
export const snormNilpotent = (x, y) => (x + y < 1 ? Math.max(x, y) : 1);
|
|
86
86
|
/**
|
|
87
87
|
* S-norm (T-conorm), dual of {@link tnormHamacher}, iff that T-norm's curve
|
|
88
88
|
* param is `p=2`.
|
|
89
89
|
*
|
|
90
|
-
* @param x
|
|
91
|
-
* @param y
|
|
90
|
+
* @param x -
|
|
91
|
+
* @param y -
|
|
92
92
|
*/
|
|
93
93
|
export const snormEinstein = (x, y) => (x + y) / (1 + x * y);
|
|
94
94
|
/**
|
|
@@ -98,7 +98,7 @@ export const snormEinstein = (x, y) => (x + y) / (1 + x * y);
|
|
|
98
98
|
* @remarks
|
|
99
99
|
* Reference: https://en.wikipedia.org/wiki/Construction_of_t-norms#Ordinal_sums
|
|
100
100
|
*
|
|
101
|
-
* @param specs
|
|
101
|
+
* @param specs -
|
|
102
102
|
*/
|
|
103
103
|
export const ordinalSum = (specs) => (x, y) => {
|
|
104
104
|
for (let s of specs) {
|
package/var.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ import type { LVar } from "./api.js";
|
|
|
15
15
|
* });
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
|
-
* @param domain
|
|
19
|
-
* @param terms
|
|
18
|
+
* @param domain -
|
|
19
|
+
* @param terms -
|
|
20
20
|
*/
|
|
21
21
|
export declare const variable: <K extends string>(domain: import("@thi.ng/api").Range, terms: import("./api.js").LVarTerms<K>) => LVar<K>;
|
|
22
22
|
/**
|
|
@@ -39,9 +39,9 @@ export declare const variable: <K extends string>(domain: import("@thi.ng/api").
|
|
|
39
39
|
* // "warm"
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
|
-
* @param var
|
|
43
|
-
* @param x
|
|
44
|
-
* @param threshold
|
|
42
|
+
* @param var -
|
|
43
|
+
* @param x -
|
|
44
|
+
* @param threshold -
|
|
45
45
|
*/
|
|
46
46
|
export declare const classify: <K extends string>({ terms }: LVar<K>, x: number, threshold?: number) => K | undefined;
|
|
47
47
|
/**
|
|
@@ -62,8 +62,8 @@ export declare const classify: <K extends string>({ terms }: LVar<K>, x: number,
|
|
|
62
62
|
* // { freezing: 0, cold: 0, warm: 0.4, hot: 0.01798620996209156 }
|
|
63
63
|
* ```
|
|
64
64
|
*
|
|
65
|
-
* @param var
|
|
66
|
-
* @param x
|
|
65
|
+
* @param var -
|
|
66
|
+
* @param x -
|
|
67
67
|
*/
|
|
68
68
|
export declare const evaluate: <K extends string>({ terms }: LVar<K>, x: number) => Record<K, number>;
|
|
69
69
|
//# sourceMappingURL=var.d.ts.map
|
package/var.js
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* });
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* @param domain
|
|
18
|
-
* @param terms
|
|
17
|
+
* @param domain -
|
|
18
|
+
* @param terms -
|
|
19
19
|
*/
|
|
20
20
|
export const variable = (domain, terms) => ({
|
|
21
21
|
domain,
|
|
@@ -41,9 +41,9 @@ export const variable = (domain, terms) => ({
|
|
|
41
41
|
* // "warm"
|
|
42
42
|
* ```
|
|
43
43
|
*
|
|
44
|
-
* @param var
|
|
45
|
-
* @param x
|
|
46
|
-
* @param threshold
|
|
44
|
+
* @param var -
|
|
45
|
+
* @param x -
|
|
46
|
+
* @param threshold -
|
|
47
47
|
*/
|
|
48
48
|
export const classify = ({ terms }, x, threshold = 0.5) => {
|
|
49
49
|
let max = threshold;
|
|
@@ -75,8 +75,8 @@ export const classify = ({ terms }, x, threshold = 0.5) => {
|
|
|
75
75
|
* // { freezing: 0, cold: 0, warm: 0.4, hot: 0.01798620996209156 }
|
|
76
76
|
* ```
|
|
77
77
|
*
|
|
78
|
-
* @param var
|
|
79
|
-
* @param x
|
|
78
|
+
* @param var -
|
|
79
|
+
* @param x -
|
|
80
80
|
*/
|
|
81
81
|
export const evaluate = ({ terms }, x) => {
|
|
82
82
|
const res = {};
|