You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/random/base/t/README.md
+92Lines changed: 92 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,10 +86,24 @@ r = rand( 3.14 );
86
86
87
87
The function accepts the following `options`:
88
88
89
+
-**prng**: pseudorandom number generator for generating uniformly distributed pseudorandom numbers on the interval `[0,1)`. If provided, the function **ignores** both the `state` and `seed` options. In order to seed the returned pseudorandom number generator, one must seed the provided `prng` (assuming the provided `prng` is seedable).
89
90
-**seed**: pseudorandom number generator seed.
90
91
-**state**: a [`Uint32Array`][@stdlib/array/uint32] containing pseudorandom number generator state. If provided, the function ignores the `seed` option.
91
92
-**copy**: `boolean` indicating whether to copy a provided pseudorandom number generator state. Setting this option to `false` allows sharing state between two or more pseudorandom number generators. Setting this option to `true` ensures that a returned generator has exclusive control over its internal state. Default: `true`.
92
93
94
+
To use a custom PRNG as the underlying source of uniformly distributed pseudorandom numbers, set the `prng` option.
95
+
96
+
```javascript
97
+
var minstd =require( '@stdlib/random/base/minstd' );
98
+
99
+
var rand =rt.factory({
100
+
'prng':minstd.normalized
101
+
});
102
+
103
+
var r =rand( 3.0 );
104
+
// returns <number>
105
+
```
106
+
93
107
To seed a pseudorandom number generator, set the `seed` option.
94
108
95
109
```javascript
@@ -175,6 +189,19 @@ for ( i = 0; i < 100; i++ ) {
175
189
}
176
190
```
177
191
192
+
If provided a PRNG for uniformly distributed numbers, this value is `null`.
193
+
194
+
<!-- eslint-disable stdlib/no-builtin-math -->
195
+
196
+
```javascript
197
+
var rand =rt.factory({
198
+
'prng':Math.random
199
+
});
200
+
201
+
var seed =rand.seed;
202
+
// returns null
203
+
```
204
+
178
205
#### t.seedLength
179
206
180
207
Length of generator seed.
@@ -184,6 +211,19 @@ var len = t.seedLength;
184
211
// returns <number>
185
212
```
186
213
214
+
If provided a PRNG for uniformly distributed numbers, this value is `null`.
215
+
216
+
<!-- eslint-disable stdlib/no-builtin-math -->
217
+
218
+
```javascript
219
+
var rand =rt.factory({
220
+
'prng':Math.random
221
+
});
222
+
223
+
var len =rand.seedLength;
224
+
// returns null
225
+
```
226
+
187
227
#### t.state
188
228
189
229
Writable property for getting and setting the generator state.
@@ -220,6 +260,19 @@ r = t( 10.0 );
220
260
// ...
221
261
```
222
262
263
+
If provided a PRNG for uniformly distributed numbers, this value is `null`.
264
+
265
+
<!-- eslint-disable stdlib/no-builtin-math -->
266
+
267
+
```javascript
268
+
var rand =rt.factory({
269
+
'prng':Math.random
270
+
});
271
+
272
+
var state =rand.state;
273
+
// returns null
274
+
```
275
+
223
276
#### t.stateLength
224
277
225
278
Length of generator state.
@@ -229,6 +282,19 @@ var len = t.stateLength;
229
282
// returns <number>
230
283
```
231
284
285
+
If provided a PRNG for uniformly distributed numbers, this value is `null`.
286
+
287
+
<!-- eslint-disable stdlib/no-builtin-math -->
288
+
289
+
```javascript
290
+
var rand =rt.factory({
291
+
'prng':Math.random
292
+
});
293
+
294
+
var len =rand.stateLength;
295
+
// returns null
296
+
```
297
+
232
298
#### t.byteLength
233
299
234
300
Size (in bytes) of generator state.
@@ -238,6 +304,19 @@ var sz = t.byteLength;
238
304
// returns <number>
239
305
```
240
306
307
+
If provided a PRNG for uniformly distributed numbers, this value is `null`.
308
+
309
+
<!-- eslint-disable stdlib/no-builtin-math -->
310
+
311
+
```javascript
312
+
var rand =rt.factory({
313
+
'prng':Math.random
314
+
});
315
+
316
+
var sz =rand.byteLength;
317
+
// returns null
318
+
```
319
+
241
320
#### t.toJSON()
242
321
243
322
Serializes the pseudorandom number generator as a JSON object.
// If we are provided an "external" PRNG, we don't support getting or setting PRNG state, as we'd need to check for compatible state value types, etc, entailing considerable complexity.
0 commit comments