ts-gaussian 3.0.4 → 4.0.3

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.
Files changed (3) hide show
  1. package/README.md +18 -18
  2. package/dist/src/index.js +6 -19
  3. package/package.json +24 -13
package/README.md CHANGED
@@ -1,46 +1,46 @@
1
- # ts-gaussian [![npm](https://img.shields.io/npm/v/ts-gaussian.svg?maxAge=3600)](https://www.npmjs.com/package/ts-gaussian) [![coverage status](https://codecov.io/gh/scttcper/ts-gaussian/branch/master/graph/badge.svg)](https://codecov.io/gh/scttcper/ts-gaussian)
1
+ # ts-gaussian [![npm](https://img.shields.io/npm/v/ts-gaussian.svg?maxAge=3600)](https://www.npmjs.com/package/ts-gaussian)
2
2
 
3
3
  > A JavaScript model of the [Normal](http://en.wikipedia.org/wiki/Normal_distribution)
4
- (or Gaussian) distribution.
4
+ > (or Gaussian) distribution.
5
5
 
6
- __API Docs__: https://ts-gaussian.vercel.app
6
+ **API Docs**: https://ts-gaussian.vercel.app
7
7
 
8
8
  ## Creating a Distribution
9
9
 
10
10
  ```ts
11
11
  import { Gaussian } from 'ts-gaussian';
12
12
  const distribution = new Gaussian(0, 1);
13
- // Take a random sample using inverse transform sampling method.
13
+ // Take a random sample using the inverse transform sampling method.
14
14
  const sample = distribution.ppf(Math.random());
15
15
  // 0.5071973169873031 or something similar
16
16
  ```
17
17
 
18
18
  ## Properties
19
19
 
20
- * `mean`: the mean (μ) of the distribution
21
- * `variance`: the variance (σ^2) of the distribution
22
- * `standardDeviation`: the standard deviation (σ) of the distribution
20
+ - `mean`: the mean (μ) of the distribution
21
+ - `variance`: the variance (σ^2) of the distribution
22
+ - `standardDeviation`: the standard deviation (σ) of the distribution
23
23
 
24
24
  ## Probability Functions
25
25
 
26
- * `pdf(x)`: the probability density function, which describes the probability
26
+ - `pdf(x)`: the probability density function, which describes the probability
27
27
  of a random variable taking on the value _x_
28
- * `cdf(x)`: the cumulative distribution function, which describes the probability of a random variable falling in the interval (−∞, _x_]
29
- * `ppf(x)`: the percent point function, the inverse of _cdf_
28
+ - `cdf(x)`: the cumulative distribution function, which describes the probability of a random variable falling in the interval (−∞, _x_]
29
+ - `ppf(x)`: the percent point function, the inverse of _cdf_
30
30
 
31
31
  ## Combination Functions
32
32
 
33
- * `mul(d)`: returns the product distribution of this and the given distribution; equivalent to `scale(d)` when d is a constant
34
- * `div(d)`: returns the quotient distribution of this and the given distribution; equivalent to `scale(1/d)` when d is a constant
35
- * `add(d)`: returns the result of adding this and the given distribution's means and variances
36
- * `sub(d)`: returns the result of subtracting this and the given distribution's means and variances
37
- * `scale(c)`: returns the result of scaling this distribution by the given constant
33
+ - `mul(d)`: returns the product distribution of this and the given distribution; equivalent to `scale(d)` when `d` is a constant
34
+ - `div(d)`: returns the quotient distribution of this and the given distribution; equivalent to `scale(1/d)` when `d` is a constant
35
+ - `add(d)`: returns the sum of the means and variances of this distribution and the given distribution
36
+ - `sub(d)`: returns the difference of the means and variances of this distribution and the given distribution
37
+ - `scale(c)`: returns the result of scaling this distribution by the given constant
38
38
 
39
39
  ## See Also
40
40
 
41
- __ts-trueskill__: https://github.com/scttcper/ts-trueskill
41
+ **ts-trueskill**: https://github.com/scttcper/ts-trueskill
42
42
 
43
43
  ### Forked From
44
44
 
45
- __Source__: https://github.com/errcw/gaussian
46
- __ES5 Fork__: https://github.com/tomgp/gaussian
45
+ **Source**: https://github.com/errcw/gaussian
46
+ **ES5 Fork**: https://github.com/tomgp/gaussian
package/dist/src/index.js CHANGED
@@ -31,7 +31,7 @@ export function ierfc(x) {
31
31
  (1 + t * (0.99229 + t * 0.04481)) - t);
32
32
  for (let j = 0; j < 2; j++) {
33
33
  const err = erfc(r) - xx;
34
- // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
34
+ // oxlint-disable-next-line no-loss-of-precision
35
35
  r += err / (1.12837916709551257 * Math.exp(-(r * r)) - r * err);
36
36
  }
37
37
  return x < 1 ? r : -r;
@@ -40,25 +40,12 @@ export function ierfc(x) {
40
40
  * Models the [Normal](http://en.wikipedia.org/wiki/Normal_distribution) (or Gaussian) distribution.
41
41
  */
42
42
  export class Gaussian {
43
+ mean;
44
+ variance;
45
+ standardDeviation;
43
46
  constructor(mean, variance) {
44
- Object.defineProperty(this, "mean", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: mean
49
- });
50
- Object.defineProperty(this, "variance", {
51
- enumerable: true,
52
- configurable: true,
53
- writable: true,
54
- value: variance
55
- });
56
- Object.defineProperty(this, "standardDeviation", {
57
- enumerable: true,
58
- configurable: true,
59
- writable: true,
60
- value: void 0
61
- });
47
+ this.mean = mean;
48
+ this.variance = variance;
62
49
  if (variance <= 0) {
63
50
  throw new Error(`Variance must be > 0 (but was ${variance})`);
64
51
  }
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "ts-gaussian",
3
- "version": "3.0.4",
3
+ "version": "4.0.3",
4
4
  "description": "A TypeScript model of a Gaussian distribution",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "license": "MIT",
7
- "repository": "scttcper/ts-gaussian",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/scttcper/ts-gaussian.git"
10
+ },
8
11
  "homepage": "https://ts-gaussian.vercel.app",
9
12
  "keywords": [
10
13
  "typescript",
@@ -20,8 +23,8 @@
20
23
  ],
21
24
  "sideEffects": false,
22
25
  "scripts": {
23
- "lint": "eslint --ext .ts .",
24
- "lint:fix": "eslint --ext .ts --fix .",
26
+ "lint": "oxlint . && prettier --check . --experimental-cli",
27
+ "lint:fix": "oxlint . --fix && prettier --write . --log-level=error --experimental-cli",
25
28
  "prepare": "npm run build",
26
29
  "build": "tsc",
27
30
  "build:docs": "typedoc",
@@ -30,14 +33,22 @@
30
33
  "test:ci": "vitest run --coverage --reporter=default --reporter=junit --outputFile=./junit.xml"
31
34
  },
32
35
  "devDependencies": {
33
- "@ctrl/eslint-config": "3.7.0",
34
- "@sindresorhus/tsconfig": "3.0.1",
35
- "@types/node": "20.1.0",
36
- "@vitest/coverage-c8": "^0.31.0",
37
- "c8": "7.13.0",
38
- "typedoc": "0.24.6",
39
- "typescript": "5.0.4",
40
- "vitest": "0.31.0"
36
+ "@ctrl/oxlint-config": "1.2.6",
37
+ "@sindresorhus/tsconfig": "8.0.1",
38
+ "@types/node": "24.6.2",
39
+ "@vitest/coverage-v8": "3.2.4",
40
+ "oxlint": "1.19.0",
41
+ "prettier": "3.6.2",
42
+ "typedoc": "0.28.13",
43
+ "typescript": "5.9.3",
44
+ "vitest": "3.2.4"
45
+ },
46
+ "prettier": {
47
+ "singleQuote": true,
48
+ "trailingComma": "all",
49
+ "arrowParens": "avoid",
50
+ "semi": true,
51
+ "printWidth": 100
41
52
  },
42
53
  "publishConfig": {
43
54
  "access": "public",
@@ -49,6 +60,6 @@
49
60
  ]
50
61
  },
51
62
  "engines": {
52
- "node": ">=14.16"
63
+ "node": ">=20"
53
64
  }
54
65
  }