@thi.ng/random 3.2.3 → 3.2.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2021-12-13T10:26:00Z
3
+ - **Last updated**: 2022-03-11T12:13:49Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/README.md CHANGED
@@ -89,7 +89,7 @@ node --experimental-repl-await
89
89
  > const random = await import("@thi.ng/random");
90
90
  ```
91
91
 
92
- Package sizes (gzipped, pre-treeshake): ESM: 1.83 KB
92
+ Package sizes (gzipped, pre-treeshake): ESM: 1.84 KB
93
93
 
94
94
  ## Dependencies
95
95
 
@@ -160,4 +160,4 @@ If this project contributes to an academic publication, please cite it as:
160
160
 
161
161
  ## License
162
162
 
163
- © 2015 - 2021 Karsten Schmidt // Apache Software License 2.0
163
+ © 2015 - 2022 Karsten Schmidt // Apache Software License 2.0
package/coin.d.ts CHANGED
@@ -6,7 +6,7 @@ import type { IRandom } from "./api.js";
6
6
  * @remarks
7
7
  * Also see {@link fairCoin}.
8
8
  *
9
- * @param rnd
9
+ * @param rnd -
10
10
  */
11
11
  export declare const coin: (rnd?: IRandom) => boolean;
12
12
  /**
@@ -18,7 +18,7 @@ export declare const coin: (rnd?: IRandom) => boolean;
18
18
  * Reference:
19
19
  * https://en.m.wikipedia.org/wiki/Fair_coin#Fair_results_from_a_biased_coin
20
20
  *
21
- * @param rnd
21
+ * @param rnd -
22
22
  */
23
23
  export declare const fairCoin: (rnd?: IRandom) => boolean;
24
24
  //# sourceMappingURL=coin.d.ts.map
package/coin.js CHANGED
@@ -6,7 +6,7 @@ import { SYSTEM } from "./system.js";
6
6
  * @remarks
7
7
  * Also see {@link fairCoin}.
8
8
  *
9
- * @param rnd
9
+ * @param rnd -
10
10
  */
11
11
  export const coin = (rnd = SYSTEM) => rnd.float() < 0.5;
12
12
  /**
@@ -18,7 +18,7 @@ export const coin = (rnd = SYSTEM) => rnd.float() < 0.5;
18
18
  * Reference:
19
19
  * https://en.m.wikipedia.org/wiki/Fair_coin#Fair_results_from_a_biased_coin
20
20
  *
21
- * @param rnd
21
+ * @param rnd -
22
22
  */
23
23
  export const fairCoin = (rnd = SYSTEM) => {
24
24
  let a, b;
@@ -6,7 +6,7 @@ import type { IRandom } from "../api.js";
6
6
  * @remarks
7
7
  * https://en.wikipedia.org/wiki/Exponential_distribution
8
8
  *
9
- * @param rnd
9
+ * @param rnd -
10
10
  * @param lambda - event interval [0,Inf)
11
11
  */
12
12
  export declare const exponential: (rnd?: IRandom, lambda?: number) => () => number;
@@ -6,7 +6,7 @@ import { SYSTEM } from "../system.js";
6
6
  * @remarks
7
7
  * https://en.wikipedia.org/wiki/Exponential_distribution
8
8
  *
9
- * @param rnd
9
+ * @param rnd -
10
10
  * @param lambda - event interval [0,Inf)
11
11
  */
12
12
  export const exponential = (rnd = SYSTEM, lambda = 10) => lambda === 0 ? () => Infinity : () => -Math.log(1 - rnd.float(1)) / lambda;
@@ -9,7 +9,7 @@ import type { IRandom } from "../api.js";
9
9
  *
10
10
  * Reference: https://en.wikipedia.org/wiki/Geometric_distribution
11
11
  *
12
- * @param rnd
12
+ * @param rnd -
13
13
  * @param p - probability (0,1]
14
14
  */
15
15
  export declare const geometric: (rnd?: IRandom, p?: number) => () => number;
@@ -9,7 +9,7 @@ import { SYSTEM } from "../system.js";
9
9
  *
10
10
  * Reference: https://en.wikipedia.org/wiki/Geometric_distribution
11
11
  *
12
- * @param rnd
12
+ * @param rnd -
13
13
  * @param p - probability (0,1]
14
14
  */
15
15
  export const geometric = (rnd = SYSTEM, p = 0.5) => p <= 0
@@ -6,9 +6,9 @@ import type { IRandom } from "../api.js";
6
6
  * @remarks
7
7
  * Also see {@link gaussian} for alternative implementation.
8
8
  *
9
- * @param rnd
10
- * @param bias
11
- * @param sigma
9
+ * @param rnd -
10
+ * @param bias -
11
+ * @param sigma -
12
12
  */
13
13
  export declare const normal: (rnd?: IRandom, bias?: number, sigma?: number) => () => number;
14
14
  //# sourceMappingURL=normal.d.ts.map
@@ -6,9 +6,9 @@ import { SYSTEM } from "../system.js";
6
6
  * @remarks
7
7
  * Also see {@link gaussian} for alternative implementation.
8
8
  *
9
- * @param rnd
10
- * @param bias
11
- * @param sigma
9
+ * @param rnd -
10
+ * @param bias -
11
+ * @param sigma -
12
12
  */
13
13
  export const normal = (rnd = SYSTEM, bias = 0, sigma = 1) => {
14
14
  let a;
@@ -6,9 +6,9 @@ import type { IRandom } from "../api.js";
6
6
  * @remarks
7
7
  * This function is syntax sugar for `rnd.minmax()`.
8
8
  *
9
- * @param rnd
10
- * @param min
11
- * @param max
9
+ * @param rnd -
10
+ * @param min -
11
+ * @param max -
12
12
  */
13
13
  export declare const uniform: (rnd?: IRandom, min?: number, max?: number) => () => number;
14
14
  //# sourceMappingURL=uniform.d.ts.map
@@ -6,8 +6,8 @@ import { SYSTEM } from "../system.js";
6
6
  * @remarks
7
7
  * This function is syntax sugar for `rnd.minmax()`.
8
8
  *
9
- * @param rnd
10
- * @param min
11
- * @param max
9
+ * @param rnd -
10
+ * @param min -
11
+ * @param max -
12
12
  */
13
13
  export const uniform = (rnd = SYSTEM, min = 0, max = 1) => () => rnd.minmax(min, max);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/random",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
4
4
  "description": "Pseudo-random number generators w/ unified API, distributions, weighted choices, ID generation",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,18 +34,18 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.3.3",
38
- "@thi.ng/checks": "^3.1.3",
39
- "@thi.ng/errors": "^2.1.3",
40
- "@thi.ng/hex": "^2.1.3"
37
+ "@thi.ng/api": "^8.3.4",
38
+ "@thi.ng/checks": "^3.1.4",
39
+ "@thi.ng/errors": "^2.1.4",
40
+ "@thi.ng/hex": "^2.1.4"
41
41
  },
42
42
  "devDependencies": {
43
- "@microsoft/api-extractor": "^7.19.2",
44
- "@thi.ng/testament": "^0.2.3",
43
+ "@microsoft/api-extractor": "^7.19.4",
44
+ "@thi.ng/testament": "^0.2.4",
45
45
  "rimraf": "^3.0.2",
46
46
  "tools": "^0.0.1",
47
- "typedoc": "^0.22.10",
48
- "typescript": "^4.5.3"
47
+ "typedoc": "^0.22.13",
48
+ "typescript": "^4.6.2"
49
49
  },
50
50
  "keywords": [
51
51
  "binary",
@@ -153,5 +153,5 @@
153
153
  "ksuid"
154
154
  ]
155
155
  },
156
- "gitHead": "2db9dd34c0c2c60cbfde3dad0bca352b20292f5c\n"
156
+ "gitHead": "0fc692a3225c068aacafdc4cb6140cf603c67ad8\n"
157
157
  }
package/pick-random.d.ts CHANGED
@@ -3,10 +3,10 @@
3
3
  * (default: {@link SYSTEM}). The index selection will be constrained to the
4
4
  * `[start,end)` interval (default: entire array).
5
5
  *
6
- * @param src
7
- * @param rnd
8
- * @param start
9
- * @param end
6
+ * @param src -
7
+ * @param rnd -
8
+ * @param start -
9
+ * @param end -
10
10
  */
11
11
  export declare const pickRandom: <T>(src: ArrayLike<T>, rnd?: import("./system.js").SystemRandom, start?: number, end?: number) => T;
12
12
  //# sourceMappingURL=pick-random.d.ts.map
package/pick-random.js CHANGED
@@ -4,9 +4,9 @@ import { SYSTEM } from "./system.js";
4
4
  * (default: {@link SYSTEM}). The index selection will be constrained to the
5
5
  * `[start,end)` interval (default: entire array).
6
6
  *
7
- * @param src
8
- * @param rnd
9
- * @param start
10
- * @param end
7
+ * @param src -
8
+ * @param rnd -
9
+ * @param start -
10
+ * @param end -
11
11
  */
12
12
  export const pickRandom = (src, rnd = SYSTEM, start = 0, end = src.length) => src[rnd.minmax(start, end) | 0];
@@ -6,10 +6,10 @@ import type { IRandom } from "./api.js";
6
6
  * samples (or creates a new one). Returns the array. Gives up after
7
7
  * `maxTrials`.
8
8
  *
9
- * @param k
10
- * @param fn
11
- * @param existing
12
- * @param maxTrials
9
+ * @param k -
10
+ * @param fn -
11
+ * @param existing -
12
+ * @param maxTrials -
13
13
  */
14
14
  export declare const uniqueValuesFrom: (k: number, fn: Fn0<number>, existing?: number[], maxTrials?: number) => number[];
15
15
  /**
@@ -22,11 +22,11 @@ export declare const uniqueValuesFrom: (k: number, fn: Fn0<number>, existing?: n
22
22
  * Candidates are drawn from the provided `rnd` {@link IRandom} (default:
23
23
  * {@link SYSTEM}) and only `maxTrials` are attempted before giving up.
24
24
  *
25
- * @param k
26
- * @param max
27
- * @param existing
28
- * @param maxTrials
29
- * @param rnd
25
+ * @param k -
26
+ * @param max -
27
+ * @param existing -
28
+ * @param maxTrials -
29
+ * @param rnd -
30
30
  */
31
31
  export declare const uniqueIndices: (k: number, max: number, existing?: number[] | undefined, maxTrials?: number, rnd?: IRandom) => number[];
32
32
  //# sourceMappingURL=unique-indices.d.ts.map
package/unique-indices.js CHANGED
@@ -6,10 +6,10 @@ import { SYSTEM } from "./system.js";
6
6
  * samples (or creates a new one). Returns the array. Gives up after
7
7
  * `maxTrials`.
8
8
  *
9
- * @param k
10
- * @param fn
11
- * @param existing
12
- * @param maxTrials
9
+ * @param k -
10
+ * @param fn -
11
+ * @param existing -
12
+ * @param maxTrials -
13
13
  */
14
14
  export const uniqueValuesFrom = (k, fn, existing = [], maxTrials = 100) => {
15
15
  let n = 0;
@@ -36,11 +36,11 @@ export const uniqueValuesFrom = (k, fn, existing = [], maxTrials = 100) => {
36
36
  * Candidates are drawn from the provided `rnd` {@link IRandom} (default:
37
37
  * {@link SYSTEM}) and only `maxTrials` are attempted before giving up.
38
38
  *
39
- * @param k
40
- * @param max
41
- * @param existing
42
- * @param maxTrials
43
- * @param rnd
39
+ * @param k -
40
+ * @param max -
41
+ * @param existing -
42
+ * @param maxTrials -
43
+ * @param rnd -
44
44
  */
45
45
  export const uniqueIndices = (k, max, existing, maxTrials = max, rnd = SYSTEM) => {
46
46
  assert(k >= 0 && k <= max, `k must be in [0, ${max}] interval`);