es6-fuzz 6.0.9 → 7.1.0
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/CONTRIBUTING.md +87 -0
- package/Readme.md +26 -10
- package/SECURITY.md +4 -5
- package/lib/curve/constant.d.ts +4 -3
- package/lib/curve/constant.d.ts.map +1 -1
- package/lib/curve/constant.js +5 -2
- package/lib/curve/constant.js.map +1 -1
- package/lib/curve/fuzzifier.d.ts +17 -0
- package/lib/curve/fuzzifier.d.ts.map +1 -0
- package/lib/curve/fuzzifier.js +3 -0
- package/lib/curve/fuzzifier.js.map +1 -0
- package/lib/curve/fuzzy-function.d.ts +2 -1
- package/lib/curve/fuzzy-function.d.ts.map +1 -1
- package/lib/curve/fuzzy-function.js +5 -2
- package/lib/curve/fuzzy-function.js.map +1 -1
- package/lib/curve/grade.d.ts +6 -0
- package/lib/curve/grade.d.ts.map +1 -1
- package/lib/curve/grade.js +27 -4
- package/lib/curve/grade.js.map +1 -1
- package/lib/curve/reverse-grade.d.ts +11 -1
- package/lib/curve/reverse-grade.d.ts.map +1 -1
- package/lib/curve/reverse-grade.js +37 -17
- package/lib/curve/reverse-grade.js.map +1 -1
- package/lib/curve/shape.d.ts +2 -1
- package/lib/curve/shape.d.ts.map +1 -1
- package/lib/curve/shape.js +20 -16
- package/lib/curve/shape.js.map +1 -1
- package/lib/curve/sigmoid.d.ts +10 -3
- package/lib/curve/sigmoid.d.ts.map +1 -1
- package/lib/curve/sigmoid.js +20 -2
- package/lib/curve/sigmoid.js.map +1 -1
- package/lib/curve/trapezoid.d.ts +8 -0
- package/lib/curve/trapezoid.d.ts.map +1 -1
- package/lib/curve/trapezoid.js +39 -19
- package/lib/curve/trapezoid.js.map +1 -1
- package/lib/curve/triangle.d.ts +7 -0
- package/lib/curve/triangle.d.ts.map +1 -1
- package/lib/curve/triangle.js +21 -2
- package/lib/curve/triangle.js.map +1 -1
- package/lib/index.d.ts +11 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +22 -0
- package/lib/index.js.map +1 -0
- package/lib/logic.d.ts +64 -5
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +118 -42
- package/lib/logic.js.map +1 -1
- package/lib/render-examples.js +92 -36
- package/lib/render-examples.js.map +1 -1
- package/lib/svg-renderer.d.ts.map +1 -1
- package/lib/svg-renderer.js +18 -9
- package/lib/svg-renderer.js.map +1 -1
- package/package.json +25 -16
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Contributing to es6-fuzz
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in improving es6-fuzz! This guide covers the local
|
|
4
|
+
workflow and the conventions used in this repository.
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
|
|
8
|
+
- Node.js 22+ (see `engines` in [package.json](package.json))
|
|
9
|
+
- npm
|
|
10
|
+
|
|
11
|
+
`package-lock.json` is intentionally not committed, so use `npm install`
|
|
12
|
+
(not `npm ci`).
|
|
13
|
+
|
|
14
|
+
## Getting started
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
git clone https://github.com/sebs/es6-fuzz.git
|
|
18
|
+
cd es6-fuzz
|
|
19
|
+
npm install
|
|
20
|
+
npm test
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Common scripts
|
|
24
|
+
|
|
25
|
+
| Script | What it does |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `npm run build` | Clean `lib/` and compile TypeScript |
|
|
28
|
+
| `npm test` | Build, then run the test suite |
|
|
29
|
+
| `npm run test:coverage` | Run the suite with a coverage report |
|
|
30
|
+
| `npm run check` | Strict type-check (`tsc --noEmit`) without emitting |
|
|
31
|
+
| `npm run docs` | Generate the TypeDoc API site into `out/` |
|
|
32
|
+
| `npm run render-examples` | Render fuzzifier SVGs + viewer into `examples/` |
|
|
33
|
+
|
|
34
|
+
Generated output (`lib/`, `out/`, `docs/CHANGELOG.md`, `examples/`) is not
|
|
35
|
+
committed — it is produced by the build and CI pipeline.
|
|
36
|
+
|
|
37
|
+
## Tests
|
|
38
|
+
|
|
39
|
+
Tests use the built-in Node.js test runner (`node:test`) executed via `tsx`,
|
|
40
|
+
and live under [test/](test/). Test files import from the compiled `lib/`
|
|
41
|
+
output, which is why `npm test` builds first. Please add or update tests for any
|
|
42
|
+
behavior change, and keep the suite green:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm test
|
|
46
|
+
npm run check
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Coding conventions
|
|
50
|
+
|
|
51
|
+
- TypeScript in `strict` mode — no new type errors (`npm run check`).
|
|
52
|
+
- Each fuzzifier implements the `Fuzzify` contract in
|
|
53
|
+
[src/curve/fuzzifier.ts](src/curve/fuzzifier.ts) and maps a crisp input to a
|
|
54
|
+
membership degree in `0..1`.
|
|
55
|
+
- Match the style of the surrounding code.
|
|
56
|
+
|
|
57
|
+
## Commit messages
|
|
58
|
+
|
|
59
|
+
This project uses [Conventional Commits](https://www.conventionalcommits.org/)
|
|
60
|
+
prefixes — e.g. `feat:`, `fix:`, `chore:`, `ci:`, `build:`, `refactor:`,
|
|
61
|
+
`docs:`. Keep commits focused and the subject line imperative.
|
|
62
|
+
|
|
63
|
+
## Submitting changes
|
|
64
|
+
|
|
65
|
+
1. Fork and branch from `master`.
|
|
66
|
+
2. Make your change with tests and passing `npm test` / `npm run check`.
|
|
67
|
+
3. Open a pull request describing the change and the motivation.
|
|
68
|
+
|
|
69
|
+
CI runs the test suite and the strict type-check on Node 22 and 24
|
|
70
|
+
(see [.github/workflows/ci.yml](.github/workflows/ci.yml)).
|
|
71
|
+
|
|
72
|
+
## Releases
|
|
73
|
+
|
|
74
|
+
Maintainers release by bumping the version, which creates a matching tag:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm version <patch|minor|major> # postversion pushes the commit + tag
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Pushing the `v*` tag triggers the release workflow (builds, packs, and
|
|
81
|
+
generates release notes); publishing to npm is a separate, manually dispatched
|
|
82
|
+
workflow.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
By contributing you agree that your contributions are licensed under the
|
|
87
|
+
project's [MIT License](LICENSE.md).
|
package/Readme.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Fuzzy Logic in JavaScript
|
|
4
4
|
|
|
5
|
+
[](https://github.com/sebs/es6-fuzz/actions/workflows/ci.yml)
|
|
5
6
|
[](https://www.npmjs.com/package/es6-fuzz)
|
|
6
7
|
[](https://github.com/sebs/es6-fuzz/blob/master/LICENSE.md)
|
|
7
8
|
[](https://github.com/sebs/es6-fuzz)
|
|
@@ -14,12 +15,11 @@
|
|
|
14
15
|
* **Reverse Grade** - Inverted linear membership
|
|
15
16
|
* **Sigmoid** - S-shaped membership curve
|
|
16
17
|
* **Trapezoid** - Trapezoidal membership function
|
|
17
|
-
* **Triangle** - Triangular membership
|
|
18
|
-
|
|
18
|
+
* **Triangle** - Triangular membership functionve
|
|
19
19
|
## Documentation
|
|
20
20
|
|
|
21
21
|
* [API Documentation](http://sebs.github.io/es6-fuzz)
|
|
22
|
-
* [Changelog](https://github.com/sebs/es6-fuzz/
|
|
22
|
+
* [Changelog](https://github.com/sebs/es6-fuzz/releases)
|
|
23
23
|
|
|
24
24
|
## Installation
|
|
25
25
|
|
|
@@ -37,9 +37,9 @@ const result = logic
|
|
|
37
37
|
.init('noAttack', new Triangle(0, 20, 40))
|
|
38
38
|
.or('normalAttack', new Trapezoid(20, 30, 90, 100))
|
|
39
39
|
.or('enragedAttack', new Grade(90, 100))
|
|
40
|
-
.defuzzify(
|
|
40
|
+
.defuzzify(99);
|
|
41
41
|
|
|
42
|
-
console.log(result); // 'enragedAttack'
|
|
42
|
+
console.log(result.toString()); // 'enragedAttack'
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
## Temperature Example
|
|
@@ -55,7 +55,7 @@ const result = logic
|
|
|
55
55
|
.or('hot', new Trapezoid(12, 14, 16, 100))
|
|
56
56
|
.defuzzify(20);
|
|
57
57
|
|
|
58
|
-
console.log(result); // 'hot'
|
|
58
|
+
console.log(result.toString()); // 'hot'
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
|
|
@@ -104,19 +104,35 @@ console.log(monsterBiteTest(jsBoonInput)); // true
|
|
|
104
104
|
### Running Tests
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
|
-
npm test
|
|
107
|
+
npm test # build + run the test suite
|
|
108
|
+
npm run test:coverage # same, with a coverage report
|
|
108
109
|
```
|
|
109
110
|
|
|
110
111
|
### Building Documentation
|
|
111
112
|
|
|
112
113
|
```bash
|
|
113
|
-
npm run docs
|
|
114
|
-
|
|
114
|
+
npm run docs # Generate the TypeDoc API site into ./out
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The site is deployed to GitHub Pages automatically on every push to `master`
|
|
118
|
+
by the [Docs workflow](.github/workflows/docs.yml); `npm run docs` is for local
|
|
119
|
+
preview.
|
|
120
|
+
|
|
121
|
+
### Visual Examples
|
|
122
|
+
|
|
123
|
+
The `render-examples` script renders every fuzzifier and a few composite
|
|
124
|
+
systems (temperature/speed controllers) to SVG, plus an `index.html` viewer:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm run build # render-examples runs from the compiled output
|
|
128
|
+
npm run render-examples # writes SVGs + index.html into ./examples
|
|
115
129
|
```
|
|
116
130
|
|
|
131
|
+
Open `examples/index.html` in a browser to see the membership curves.
|
|
132
|
+
|
|
117
133
|
## Requirements
|
|
118
134
|
|
|
119
|
-
* Node.js
|
|
135
|
+
* Node.js 22+
|
|
120
136
|
|
|
121
137
|
## Resources
|
|
122
138
|
|
package/SECURITY.md
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Supported Versions
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
currently being supported with security updates.
|
|
5
|
+
The following versions of es6-fuzz are currently supported with security updates:
|
|
7
6
|
|
|
8
7
|
| Version | Supported |
|
|
9
8
|
| ------- | ------------------ |
|
|
10
|
-
|
|
|
11
|
-
| 5.
|
|
12
|
-
| 4.
|
|
9
|
+
| 6.0.x | :white_check_mark: |
|
|
10
|
+
| 5.x.x | :x: |
|
|
11
|
+
| 4.x.x | :x: |
|
|
13
12
|
| < 4.0 | :x: |
|
|
14
13
|
|
|
15
14
|
## Reporting a Vulnerability
|
package/lib/curve/constant.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { Fuzzifier } from './fuzzifier';
|
|
1
2
|
/** Class representing a Constant. */
|
|
2
|
-
export declare class Constant {
|
|
3
|
+
export declare class Constant implements Fuzzifier {
|
|
3
4
|
private readonly cValue;
|
|
4
5
|
/**
|
|
5
6
|
* Create a Constant Value.
|
|
6
|
-
* @param {number} constantValue - The value.
|
|
7
|
+
* @param {number} constantValue - The membership value, must be within 0..1.
|
|
7
8
|
* @example
|
|
8
|
-
* new Constant(
|
|
9
|
+
* new Constant(0.5)
|
|
9
10
|
*/
|
|
10
11
|
constructor(constantValue: number);
|
|
11
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/curve/constant.ts"],"names":[],"mappings":"AACA,qCAAqC;AACrC,qBAAa,
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/curve/constant.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,qCAAqC;AACrC,qBAAa,QAAS,YAAW,SAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,aAAa,EAAE,MAAM;IAMjC;;;OAGG;IACH,OAAO,IAAI,MAAM;CAGlB"}
|
package/lib/curve/constant.js
CHANGED
|
@@ -6,11 +6,14 @@ class Constant {
|
|
|
6
6
|
cValue;
|
|
7
7
|
/**
|
|
8
8
|
* Create a Constant Value.
|
|
9
|
-
* @param {number} constantValue - The value.
|
|
9
|
+
* @param {number} constantValue - The membership value, must be within 0..1.
|
|
10
10
|
* @example
|
|
11
|
-
* new Constant(
|
|
11
|
+
* new Constant(0.5)
|
|
12
12
|
*/
|
|
13
13
|
constructor(constantValue) {
|
|
14
|
+
if (!(constantValue >= 0 && constantValue <= 1)) {
|
|
15
|
+
throw Error('Constant value must be between 0 and 1 but is ' + constantValue);
|
|
16
|
+
}
|
|
14
17
|
this.cValue = constantValue;
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/curve/constant.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/curve/constant.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,qCAAqC;AACrC,MAAa,QAAQ;IACF,MAAM,CAAS;IAEhC;;;;;OAKG;IACH,YAAY,aAAqB;QAC/B,IAAI,CAAC,CAAC,aAAa,IAAI,CAAC,IAAI,aAAa,IAAI,CAAC,CAAC,EAAE,CAAC;YAChD,MAAM,KAAK,CAAC,gDAAgD,GAAG,aAAa,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;IAC9B,CAAC;IACD;;;OAGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAtBD,4BAsBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common interface implemented by every fuzzifier.
|
|
3
|
+
*
|
|
4
|
+
* Anything that maps a crisp input value to a membership degree can be used
|
|
5
|
+
* with {@link Logic}. This includes the geometric {@link Shape} curves as well
|
|
6
|
+
* as {@link Constant}, {@link Sigmoid} and {@link FuzzyFunction}, none of which
|
|
7
|
+
* are point-based shapes.
|
|
8
|
+
*/
|
|
9
|
+
export interface Fuzzifier {
|
|
10
|
+
/**
|
|
11
|
+
* Fuzzify
|
|
12
|
+
* @param {number} val - Point on X axis
|
|
13
|
+
* @return {number} fuzzy output 0..1
|
|
14
|
+
*/
|
|
15
|
+
fuzzify(val: number): number;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=fuzzifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuzzifier.d.ts","sourceRoot":"","sources":["../../src/curve/fuzzifier.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuzzifier.js","sourceRoot":"","sources":["../../src/curve/fuzzifier.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuzzy-function.d.ts","sourceRoot":"","sources":["../../src/curve/fuzzy-function.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,qBAAa,
|
|
1
|
+
{"version":3,"file":"fuzzy-function.d.ts","sourceRoot":"","sources":["../../src/curve/fuzzy-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,0CAA0C;AAC1C,qBAAa,aAAc,YAAW,SAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA0B;IAE7C;;;OAGG;gBACS,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM;IAGvC;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAU7B"}
|
|
@@ -17,10 +17,13 @@ class FuzzyFunction {
|
|
|
17
17
|
*/
|
|
18
18
|
fuzzify(val) {
|
|
19
19
|
const res = this.cb(val);
|
|
20
|
-
|
|
20
|
+
// The relational checks coerce their operands, so a non-number (string,
|
|
21
|
+
// boolean, null, array) could pass `res >= 0 && res <= 1` and be returned
|
|
22
|
+
// verbatim, breaking the `number` contract. Require an actual number.
|
|
23
|
+
if (typeof res === 'number' && res >= 0 && res <= 1) {
|
|
21
24
|
return res;
|
|
22
25
|
}
|
|
23
|
-
throw Error('fuzzified result must be
|
|
26
|
+
throw Error('fuzzified result must be between 0 and 1 but is ' + res);
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
exports.FuzzyFunction = FuzzyFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuzzy-function.js","sourceRoot":"","sources":["../../src/curve/fuzzy-function.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"fuzzy-function.js","sourceRoot":"","sources":["../../src/curve/fuzzy-function.ts"],"names":[],"mappings":";;;AACA,0CAA0C;AAC1C,MAAa,aAAa;IACP,EAAE,CAA0B;IAE7C;;;OAGG;IACH,YAAY,EAA2B;QACrC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD;;;OAGG;IACH,OAAO,CAAC,GAAW;QACjB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACzB,wEAAwE;QACxE,0EAA0E;QAC1E,sEAAsE;QACtE,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;YACpD,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,KAAK,CAAC,kDAAkD,GAAG,GAAG,CAAC,CAAC;IACxE,CAAC;CACF;AAxBD,sCAwBC"}
|
package/lib/curve/grade.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ import { Shape } from './shape';
|
|
|
5
5
|
* new Grade(0, 10)
|
|
6
6
|
*/
|
|
7
7
|
export declare class Grade extends Shape {
|
|
8
|
+
/**
|
|
9
|
+
* Create a Grade.
|
|
10
|
+
* @param {number} x0 - start of the rising edge (membership 0)
|
|
11
|
+
* @param {number} x1 - end of the rising edge (membership 1)
|
|
12
|
+
*/
|
|
13
|
+
constructor(x0: number, x1: number);
|
|
8
14
|
/**
|
|
9
15
|
* Fuzzify
|
|
10
16
|
* @param {number} val - Point on X axis
|
package/lib/curve/grade.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grade.d.ts","sourceRoot":"","sources":["../../src/curve/grade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC;;;;GAIG;AACH,qBAAa,KAAM,SAAQ,KAAK;IAC9B;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"grade.d.ts","sourceRoot":"","sources":["../../src/curve/grade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC;;;;GAIG;AACH,qBAAa,KAAM,SAAQ,KAAK;IAC9B;;;;OAIG;gBACS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAUlC;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CA2B7B"}
|
package/lib/curve/grade.js
CHANGED
|
@@ -8,6 +8,21 @@ const shape_1 = require("./shape");
|
|
|
8
8
|
* new Grade(0, 10)
|
|
9
9
|
*/
|
|
10
10
|
class Grade extends shape_1.Shape {
|
|
11
|
+
/**
|
|
12
|
+
* Create a Grade.
|
|
13
|
+
* @param {number} x0 - start of the rising edge (membership 0)
|
|
14
|
+
* @param {number} x1 - end of the rising edge (membership 1)
|
|
15
|
+
*/
|
|
16
|
+
constructor(x0, x1) {
|
|
17
|
+
super(x0, x1, x1, x1);
|
|
18
|
+
// Reject reversed finite params: with x0 > x1 the `x <= x0` guard swallows
|
|
19
|
+
// the whole interior, so the ramp collapses into a hard step and the linear
|
|
20
|
+
// branch becomes dead code. NaN/Infinity are left untouched (handled at
|
|
21
|
+
// fuzzify time and relied on by callers passing open-ended bounds).
|
|
22
|
+
if (Number.isFinite(x0) && Number.isFinite(x1) && x0 > x1) {
|
|
23
|
+
throw Error('Grade requires x0 <= x1 but got x0=' + x0 + ', x1=' + x1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
11
26
|
/**
|
|
12
27
|
* Fuzzify
|
|
13
28
|
* @param {number} val - Point on X axis
|
|
@@ -16,11 +31,16 @@ class Grade extends shape_1.Shape {
|
|
|
16
31
|
fuzzify(val) {
|
|
17
32
|
let result = 0;
|
|
18
33
|
const x = val;
|
|
19
|
-
//
|
|
34
|
+
// NaN has no meaningful membership; treat it as outside the ramp (0).
|
|
35
|
+
if (Number.isNaN(x))
|
|
36
|
+
return 0;
|
|
37
|
+
// Handle case where x0 = x1 (vertical grade/step function).
|
|
38
|
+
// Treat it as the limit of the ramp: the foot at x0 is 0, like the normal
|
|
39
|
+
// grade below, so behaviour stays continuous as x1 approaches x0.
|
|
20
40
|
if (this.x1 === this.x0) {
|
|
21
|
-
if (x
|
|
41
|
+
if (x <= this.x0)
|
|
22
42
|
return 0;
|
|
23
|
-
return 1; // x
|
|
43
|
+
return 1; // x > x0
|
|
24
44
|
}
|
|
25
45
|
if (x <= this.x0) {
|
|
26
46
|
result = 0;
|
|
@@ -29,7 +49,10 @@ class Grade extends shape_1.Shape {
|
|
|
29
49
|
result = 1;
|
|
30
50
|
}
|
|
31
51
|
else {
|
|
32
|
-
|
|
52
|
+
// Algebraically equal to x/(x1-x0) - x0/(x1-x0) but numerically stable:
|
|
53
|
+
// the split form subtracts two large nearly-equal quotients and loses
|
|
54
|
+
// significance for large coordinates (see Grade large-coordinate bug).
|
|
55
|
+
result = (x - this.x0) / (this.x1 - this.x0);
|
|
33
56
|
}
|
|
34
57
|
return result;
|
|
35
58
|
}
|
package/lib/curve/grade.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grade.js","sourceRoot":"","sources":["../../src/curve/grade.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAgC;AAChC;;;;GAIG;AACH,MAAa,KAAM,SAAQ,aAAK;IAC9B;;;;OAIG;IACH,OAAO,CAAC,GAAW;QACjB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,GAAG,GAAG,CAAC;QAEd,
|
|
1
|
+
{"version":3,"file":"grade.js","sourceRoot":"","sources":["../../src/curve/grade.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAgC;AAChC;;;;GAIG;AACH,MAAa,KAAM,SAAQ,aAAK;IAC9B;;;;OAIG;IACH,YAAY,EAAU,EAAE,EAAU;QAChC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACtB,2EAA2E;QAC3E,4EAA4E;QAC5E,wEAAwE;QACxE,oEAAoE;QACpE,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;YAC1D,MAAM,KAAK,CAAC,qCAAqC,GAAG,EAAE,GAAG,OAAO,GAAG,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IACD;;;;OAIG;IACH,OAAO,CAAC,GAAW;QACjB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,GAAG,GAAG,CAAC;QAEd,sEAAsE;QACtE,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;QAE9B,4DAA4D;QAC5D,0EAA0E;QAC1E,kEAAkE;QAClE,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC;YAC3B,OAAO,CAAC,CAAC,CAAC,SAAS;QACrB,CAAC;QAED,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACxB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,wEAAwE;YACxE,sEAAsE;YACtE,uEAAuE;YACvE,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAhDD,sBAgDC"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { Shape } from './shape';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Class representing a ReverseGrade.
|
|
4
|
+
* @example
|
|
5
|
+
* new ReverseGrade(0, 10)
|
|
6
|
+
*/
|
|
3
7
|
export declare class ReverseGrade extends Shape {
|
|
8
|
+
/**
|
|
9
|
+
* Create a ReverseGrade.
|
|
10
|
+
* @param {number} x0 - end of the full-membership plateau (membership 1)
|
|
11
|
+
* @param {number} x1 - end of the falling edge (membership 0)
|
|
12
|
+
*/
|
|
13
|
+
constructor(x0: number, x1: number);
|
|
4
14
|
/**
|
|
5
15
|
* Fuzzify
|
|
6
16
|
* @param {number} val - Point on X axis
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse-grade.d.ts","sourceRoot":"","sources":["../../src/curve/reverse-grade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC
|
|
1
|
+
{"version":3,"file":"reverse-grade.d.ts","sourceRoot":"","sources":["../../src/curve/reverse-grade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC;;;;OAIG;gBACS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IASlC;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAqB7B"}
|
|
@@ -2,32 +2,52 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReverseGrade = void 0;
|
|
4
4
|
const shape_1 = require("./shape");
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a ReverseGrade.
|
|
7
|
+
* @example
|
|
8
|
+
* new ReverseGrade(0, 10)
|
|
9
|
+
*/
|
|
6
10
|
class ReverseGrade extends shape_1.Shape {
|
|
11
|
+
/**
|
|
12
|
+
* Create a ReverseGrade.
|
|
13
|
+
* @param {number} x0 - end of the full-membership plateau (membership 1)
|
|
14
|
+
* @param {number} x1 - end of the falling edge (membership 0)
|
|
15
|
+
*/
|
|
16
|
+
constructor(x0, x1) {
|
|
17
|
+
super(x0, x1, x1, x1);
|
|
18
|
+
// Reject reversed finite params: with x0 > x1 the falling edge collapses
|
|
19
|
+
// into a hard step and the linear branch becomes dead code. NaN/Infinity
|
|
20
|
+
// are left untouched (handled at fuzzify time).
|
|
21
|
+
if (Number.isFinite(x0) && Number.isFinite(x1) && x0 > x1) {
|
|
22
|
+
throw Error('ReverseGrade requires x0 <= x1 but got x0=' + x0 + ', x1=' + x1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
7
25
|
/**
|
|
8
26
|
* Fuzzify
|
|
9
27
|
* @param {number} val - Point on X axis
|
|
10
28
|
* @return {number} fuzzy output 0..1
|
|
11
29
|
*/
|
|
12
30
|
fuzzify(val) {
|
|
13
|
-
let result = 0;
|
|
14
31
|
const x = val;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
result = (-x / (this.x1 - this.x0)) + (this.x1 / (this.x1 - this.x0));
|
|
28
|
-
}
|
|
32
|
+
// NaN has no meaningful membership; treat it as outside the ramp (0).
|
|
33
|
+
if (Number.isNaN(x))
|
|
34
|
+
return 0;
|
|
35
|
+
// Vertical reverse grade (x0 = x1): step down, the mirror of Grade.
|
|
36
|
+
// (The previous inline x0 === x1 handling sat in an unreachable branch:
|
|
37
|
+
// when x0 === x1 every value is caught by x <= x0 or x >= x1 first.)
|
|
38
|
+
if (this.x1 === this.x0) {
|
|
39
|
+
if (x <= this.x0)
|
|
40
|
+
return 1;
|
|
41
|
+
return 0; // x > x0
|
|
29
42
|
}
|
|
30
|
-
|
|
43
|
+
if (x <= this.x0)
|
|
44
|
+
return 1;
|
|
45
|
+
if (x >= this.x1)
|
|
46
|
+
return 0;
|
|
47
|
+
// Algebraically equal to -x/(x1-x0) + x1/(x1-x0) but numerically stable:
|
|
48
|
+
// the split form adds two large nearly-equal quotients and loses
|
|
49
|
+
// significance for large coordinates.
|
|
50
|
+
return (this.x1 - x) / (this.x1 - this.x0);
|
|
31
51
|
}
|
|
32
52
|
}
|
|
33
53
|
exports.ReverseGrade = ReverseGrade;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse-grade.js","sourceRoot":"","sources":["../../src/curve/reverse-grade.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAgC;AAChC
|
|
1
|
+
{"version":3,"file":"reverse-grade.js","sourceRoot":"","sources":["../../src/curve/reverse-grade.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAgC;AAChC;;;;GAIG;AACH,MAAa,YAAa,SAAQ,aAAK;IACrC;;;;OAIG;IACH,YAAY,EAAU,EAAE,EAAU;QAChC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACtB,yEAAyE;QACzE,yEAAyE;QACzE,gDAAgD;QAChD,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;YAC1D,MAAM,KAAK,CAAC,4CAA4C,GAAG,EAAE,GAAG,OAAO,GAAG,EAAE,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IACD;;;;OAIG;IACH,OAAO,CAAC,GAAW;QACjB,MAAM,CAAC,GAAG,GAAG,CAAC;QAEd,sEAAsE;QACtE,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;QAE9B,oEAAoE;QACpE,wEAAwE;QACxE,qEAAqE;QACrE,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC;YAC3B,OAAO,CAAC,CAAC,CAAC,SAAS;QACrB,CAAC;QAED,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;YAAE,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;YAAE,OAAO,CAAC,CAAC;QAC3B,yEAAyE;QACzE,iEAAiE;QACjE,sCAAsC;QACtC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF;AAzCD,oCAyCC"}
|
package/lib/curve/shape.d.ts
CHANGED
package/lib/curve/shape.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/curve/shape.ts"],"names":[],"mappings":"AACA,uCAAuC;AACvC,8BAAsB,
|
|
1
|
+
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/curve/shape.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,uCAAuC;AACvC,8BAAsB,KAAM,YAAW,SAAS;IAC9C,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IAErB;;;;;;OAMG;gBACS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAuB1D;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CACtC"}
|
package/lib/curve/shape.js
CHANGED
|
@@ -15,22 +15,26 @@ class Shape {
|
|
|
15
15
|
* @param {number} x3 - x3
|
|
16
16
|
*/
|
|
17
17
|
constructor(x0, x1, x2, x3) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
// Define the coordinates as truly immutable: not writable AND not
|
|
19
|
+
// configurable, so they can't be reassigned, deleted or redefined. With
|
|
20
|
+
// useDefineForClassFields the field declarations above otherwise leave them
|
|
21
|
+
// configurable:true, letting `delete shape.x0` or a redefine defeat the
|
|
22
|
+
// read-only intent. They stay enumerable so they remain visible as the
|
|
23
|
+
// documented public properties (e.g. in JSON.stringify).
|
|
24
|
+
const coords = [
|
|
25
|
+
['x0', x0],
|
|
26
|
+
['x1', x1],
|
|
27
|
+
['x2', x2],
|
|
28
|
+
['x3', x3],
|
|
29
|
+
];
|
|
30
|
+
for (const [name, value] of coords) {
|
|
31
|
+
Object.defineProperty(this, name, {
|
|
32
|
+
value,
|
|
33
|
+
writable: false,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: false,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
exports.Shape = Shape;
|
package/lib/curve/shape.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.js","sourceRoot":"","sources":["../../src/curve/shape.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;
|
|
1
|
+
{"version":3,"file":"shape.js","sourceRoot":"","sources":["../../src/curve/shape.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,uCAAuC;AACvC,MAAsB,KAAK;IAChB,EAAE,CAAU;IACZ,EAAE,CAAU;IACZ,EAAE,CAAU;IACZ,EAAE,CAAU;IAErB;;;;;;OAMG;IACH,YAAY,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU;QACxD,kEAAkE;QAClE,wEAAwE;QACxE,4EAA4E;QAC5E,wEAAwE;QACxE,uEAAuE;QACvE,yDAAyD;QACzD,MAAM,MAAM,GAA4B;YACtC,CAAC,IAAI,EAAE,EAAE,CAAC;YACV,CAAC,IAAI,EAAE,EAAE,CAAC;YACV,CAAC,IAAI,EAAE,EAAE,CAAC;YACV,CAAC,IAAI,EAAE,EAAE,CAAC;SACX,CAAC;QACF,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,EAAE,CAAC;YACnC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE;gBAChC,KAAK;gBACL,QAAQ,EAAE,KAAK;gBACf,UAAU,EAAE,IAAI;gBAChB,YAAY,EAAE,KAAK;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CAQF;AA1CD,sBA0CC"}
|
package/lib/curve/sigmoid.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fuzzifier } from './fuzzifier';
|
|
1
2
|
/**
|
|
2
3
|
* Class representing a Sigmoid.
|
|
3
4
|
* @example
|
|
@@ -5,13 +6,19 @@
|
|
|
5
6
|
* sigmoid = new Sigmoid(0, 100000);
|
|
6
7
|
* sigmoid2.fuzzify(10);
|
|
7
8
|
*/
|
|
8
|
-
export declare class Sigmoid {
|
|
9
|
+
export declare class Sigmoid implements Fuzzifier {
|
|
9
10
|
private readonly center;
|
|
10
11
|
private readonly slope;
|
|
11
12
|
/**
|
|
12
13
|
* Create a Sigmoid Function.
|
|
13
|
-
* @param {number} center - The center point of the sigmoid curve (where it outputs 0.5)
|
|
14
|
-
*
|
|
14
|
+
* @param {number} center - The center point of the sigmoid curve (where it outputs 0.5).
|
|
15
|
+
* Must be finite.
|
|
16
|
+
* @param {number} slope - Width of the transition: it appears in the denominator
|
|
17
|
+
* as 1 / (1 + exp(-(x - center) / slope)), so a smaller magnitude means a steeper
|
|
18
|
+
* transition and a larger magnitude a gentler one. A **negative** slope inverts the
|
|
19
|
+
* curve into a decreasing S (high membership below the center, low above). A slope of
|
|
20
|
+
* `0` degenerates to an increasing step at the center (0.5 exactly at the center).
|
|
21
|
+
* Must be finite; non-finite center/slope throw.
|
|
15
22
|
*/
|
|
16
23
|
constructor(center?: number, slope?: number);
|
|
17
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sigmoid.d.ts","sourceRoot":"","sources":["../../src/curve/sigmoid.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,qBAAa,
|
|
1
|
+
{"version":3,"file":"sigmoid.d.ts","sourceRoot":"","sources":["../../src/curve/sigmoid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC;;;;;;GAMG;AACH,qBAAa,OAAQ,YAAW,SAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B;;;;;;;;;;OAUG;gBACS,MAAM,GAAE,MAAU,EAAE,KAAK,GAAE,MAAU;IAajD;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;CAW3B"}
|
package/lib/curve/sigmoid.js
CHANGED
|
@@ -13,10 +13,25 @@ class Sigmoid {
|
|
|
13
13
|
slope;
|
|
14
14
|
/**
|
|
15
15
|
* Create a Sigmoid Function.
|
|
16
|
-
* @param {number} center - The center point of the sigmoid curve (where it outputs 0.5)
|
|
17
|
-
*
|
|
16
|
+
* @param {number} center - The center point of the sigmoid curve (where it outputs 0.5).
|
|
17
|
+
* Must be finite.
|
|
18
|
+
* @param {number} slope - Width of the transition: it appears in the denominator
|
|
19
|
+
* as 1 / (1 + exp(-(x - center) / slope)), so a smaller magnitude means a steeper
|
|
20
|
+
* transition and a larger magnitude a gentler one. A **negative** slope inverts the
|
|
21
|
+
* curve into a decreasing S (high membership below the center, low above). A slope of
|
|
22
|
+
* `0` degenerates to an increasing step at the center (0.5 exactly at the center).
|
|
23
|
+
* Must be finite; non-finite center/slope throw.
|
|
18
24
|
*/
|
|
19
25
|
constructor(center = 0, slope = 1) {
|
|
26
|
+
// Validate up front (like Constant/FuzzyFunction): a non-finite center or
|
|
27
|
+
// slope makes fuzzify return NaN, breaking the documented 0..1 contract and
|
|
28
|
+
// making defuzzify report no winner ('none') for an otherwise valid rule.
|
|
29
|
+
if (!Number.isFinite(center)) {
|
|
30
|
+
throw Error('Sigmoid center must be a finite number but is ' + center);
|
|
31
|
+
}
|
|
32
|
+
if (!Number.isFinite(slope)) {
|
|
33
|
+
throw Error('Sigmoid slope must be a finite number but is ' + slope);
|
|
34
|
+
}
|
|
20
35
|
this.center = center;
|
|
21
36
|
this.slope = slope;
|
|
22
37
|
}
|
|
@@ -26,6 +41,9 @@ class Sigmoid {
|
|
|
26
41
|
* @return {number} fuzzy output 0..1
|
|
27
42
|
*/
|
|
28
43
|
fuzzify(x) {
|
|
44
|
+
// NaN has no meaningful membership; treat it as 0 instead of returning NaN.
|
|
45
|
+
if (Number.isNaN(x))
|
|
46
|
+
return 0;
|
|
29
47
|
if (this.slope === 0) {
|
|
30
48
|
// When slope is 0, sigmoid becomes a step function
|
|
31
49
|
if (x < this.center)
|