@thi.ng/random 4.1.10 → 4.1.12
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 +3 -2
- package/api.d.ts +7 -7
- package/distributions/gaussian.d.ts +1 -1
- package/distributions/geometric.d.ts +1 -1
- package/package.json +6 -6
- package/sfc32.d.ts +2 -2
- package/smush32.d.ts +1 -1
- package/weighted-probability.d.ts +2 -2
- package/xoshiro128.d.ts +1 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 202 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -121,7 +121,7 @@ Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
|
|
|
121
121
|
|
|
122
122
|
## Usage examples
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
19 projects in this repo's
|
|
125
125
|
[/examples](https://github.com/thi-ng/umbrella/tree/develop/examples)
|
|
126
126
|
directory are using this package:
|
|
127
127
|
|
|
@@ -144,6 +144,7 @@ directory are using this package:
|
|
|
144
144
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/shader-ast-evo.jpg" width="240"/> | Evolutionary shader generation using genetic programming | [Demo](https://demo.thi.ng/umbrella/shader-ast-evo/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-evo) |
|
|
145
145
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/stacked-layout.png" width="240"/> | Responsive & reactively computed stacked column layout | [Demo](https://demo.thi.ng/umbrella/stacked-layout/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/stacked-layout) |
|
|
146
146
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/thing-packages-quiz.avif" width="240"/> | thi.ng/rdom & thi.ng/rstream based quiz to guess thi.ng package names | [Demo](https://demo.thi.ng/umbrella/thing-packages-quiz/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/thing-packages-quiz) |
|
|
147
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/tsne-colors.avif" width="240"/> | Animated t-SNE visualization of 4D data | [Demo](https://demo.thi.ng/umbrella/tsne-colors/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/tsne-colors) |
|
|
147
148
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-game-of-life.png" width="240"/> | Game of Life implemented as WebGL2 multi-pass shader pipeline | [Demo](https://demo.thi.ng/umbrella/webgl-game-of-life/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-game-of-life) |
|
|
148
149
|
|
|
149
150
|
## API
|
package/api.d.ts
CHANGED
|
@@ -27,14 +27,14 @@ export interface INorm {
|
|
|
27
27
|
}
|
|
28
28
|
export interface IRandom extends INorm {
|
|
29
29
|
/**
|
|
30
|
-
* Returns unsigned 32bit int in [0
|
|
30
|
+
* Returns unsigned 32bit int in `[0,0xffffffff]` interval.
|
|
31
31
|
*
|
|
32
32
|
* @remarks
|
|
33
33
|
* See: https://github.com/thi-ng/umbrella/wiki/Glossary#interval
|
|
34
34
|
*/
|
|
35
35
|
int(): number;
|
|
36
36
|
/**
|
|
37
|
-
* Returns float in [0
|
|
37
|
+
* Returns float in `[0,max)` interval.
|
|
38
38
|
*
|
|
39
39
|
* @remarks
|
|
40
40
|
* See: https://github.com/thi-ng/umbrella/wiki/Glossary#interval
|
|
@@ -43,14 +43,14 @@ export interface IRandom extends INorm {
|
|
|
43
43
|
*/
|
|
44
44
|
float(max?: number): number;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* Calls {@link IRandom.float} and returns true iff result is < `p` (assumed
|
|
47
|
+
* to be in `[0,1]` interval).
|
|
48
48
|
*
|
|
49
49
|
* @param p
|
|
50
50
|
*/
|
|
51
51
|
probability(p: number): boolean;
|
|
52
52
|
/**
|
|
53
|
-
* Returns float in [min
|
|
53
|
+
* Returns float in `[min,max)` interval.
|
|
54
54
|
*
|
|
55
55
|
* @remarks
|
|
56
56
|
* See: https://github.com/thi-ng/umbrella/wiki/Glossary#interval
|
|
@@ -60,7 +60,7 @@ export interface IRandom extends INorm {
|
|
|
60
60
|
*/
|
|
61
61
|
minmax(min: number, max: number): number;
|
|
62
62
|
/**
|
|
63
|
-
* Returns int in **signed** integer [min
|
|
63
|
+
* Returns int in **signed** integer `[min,max)` interval.
|
|
64
64
|
*
|
|
65
65
|
* @remarks
|
|
66
66
|
* See: https://github.com/thi-ng/umbrella/wiki/Glossary#interval
|
|
@@ -70,7 +70,7 @@ export interface IRandom extends INorm {
|
|
|
70
70
|
*/
|
|
71
71
|
minmaxInt(min: number, max: number): number;
|
|
72
72
|
/**
|
|
73
|
-
* Returns int in **unsigned** integer [min
|
|
73
|
+
* Returns int in **unsigned** integer `[min,max)` interval.
|
|
74
74
|
*
|
|
75
75
|
* @remarks
|
|
76
76
|
* See: https://github.com/thi-ng/umbrella/wiki/Glossary#interval
|
|
@@ -5,7 +5,7 @@ import type { IRandom } from "../api.js";
|
|
|
5
5
|
* (Central Limit Theorem).
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* The default configuration produces samples in the approx. [-0.5,0.5] range
|
|
8
|
+
* The default configuration produces samples in the approx. `[-0.5,0.5]` range
|
|
9
9
|
* with a ~12% standard deviation.
|
|
10
10
|
*
|
|
11
11
|
* Reference: https://en.wikipedia.org/wiki/Central_limit_theorem
|
|
@@ -10,7 +10,7 @@ import type { IRandom } from "../api.js";
|
|
|
10
10
|
* Reference: https://en.wikipedia.org/wiki/Geometric_distribution
|
|
11
11
|
*
|
|
12
12
|
* @param rnd -
|
|
13
|
-
* @param p - probability (0,1]
|
|
13
|
+
* @param p - probability `(0,1]`
|
|
14
14
|
*/
|
|
15
15
|
export declare const geometric: (rnd?: IRandom, p?: number) => () => number;
|
|
16
16
|
//# sourceMappingURL=geometric.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/random",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.12",
|
|
4
4
|
"description": "Pseudo-random number generators w/ unified API, distributions, weighted choices, ID generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@thi.ng/api": "^8.11.
|
|
43
|
-
"@thi.ng/errors": "^2.5.
|
|
42
|
+
"@thi.ng/api": "^8.11.21",
|
|
43
|
+
"@thi.ng/errors": "^2.5.27"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"esbuild": "^0.
|
|
47
|
-
"typedoc": "^0.27.
|
|
46
|
+
"esbuild": "^0.25.0",
|
|
47
|
+
"typedoc": "^0.27.7",
|
|
48
48
|
"typescript": "^5.7.3"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|
|
@@ -159,5 +159,5 @@
|
|
|
159
159
|
"ksuid"
|
|
160
160
|
]
|
|
161
161
|
},
|
|
162
|
-
"gitHead": "
|
|
162
|
+
"gitHead": "bee617702ac61d093465b967f8f973dc566faa6b\n"
|
|
163
163
|
}
|
package/sfc32.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { ARandom } from "./arandom.js";
|
|
|
5
5
|
* Simple Fast Counter PRNG (32bit version)
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Reference:
|
|
9
|
+
* http://pracrand.sourceforge.net/
|
|
10
10
|
*/
|
|
11
11
|
export declare class SFC32 extends ARandom implements IBuffered<Uint32Array>, ICopy<SFC32>, ISeedable<ArrayLike<number>> {
|
|
12
12
|
buffer: Uint32Array;
|
package/smush32.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { FnN } from "@thi.ng/api";
|
|
|
2
2
|
import type { IRandom } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Takes a `weight` function and optional {@link IRandom} instance (default:
|
|
5
|
-
* {@link SYSTEM}). The weight function accepts a number in [0,1) interval and
|
|
6
|
-
* returns a number in [0,1]
|
|
5
|
+
* {@link SYSTEM}). The weight function accepts a number in `[0,1)` interval and
|
|
6
|
+
* returns a number in `[0,1]`. Draws two random numbers `a` and `b` via
|
|
7
7
|
* {@link IRandom.float} and returns a tuple of `[a, b < weight(a)]`.
|
|
8
8
|
*
|
|
9
9
|
* @example
|