repl.txt (2715B)
1 2 {{alias}}( [options] ) 3 Create an iterator for generating uniformly distributed pseudorandom numbers 4 between 0 and 1. 5 6 The default underlying pseudorandom number generator (PRNG) *may* change in 7 the future. If exact reproducibility is required, either explicitly specify 8 a PRNG via the `name` option or use an underlying PRNG directly. 9 10 If an environment supports Symbol.iterator, the returned iterator is 11 iterable. 12 13 Parameters 14 ---------- 15 options: Object (optional) 16 Options. 17 18 options.name: string (optional) 19 Name of a supported pseudorandom number generator (PRNG), which will 20 serve as the underlying source of pseudorandom numbers. The following 21 PRNGs are supported: 22 23 - mt19937: 32-bit Mersenne Twister. 24 - minstd: linear congruential PRNG based on Park and Miller. 25 - minstd-shuffle: linear congruential PRNG whose output is shuffled. 26 27 Default: `'mt19937'`. 28 29 options.seed: any (optional) 30 Pseudorandom number generator seed. Valid seed values vary according to 31 the underlying PRNG. 32 33 options.state: any (optional) 34 Pseudorandom number generator state. Valid state values vary according 35 to the underling PRNG. If provided, the `seed` option is ignored. 36 37 options.copy: boolean (optional) 38 Boolean indicating whether to copy a provided pseudorandom number 39 generator state. Setting this option to `false` allows sharing state 40 between two or more pseudorandom number generators. Setting this option 41 to `true` ensures that a returned generator has exclusive control over 42 its internal state. Default: true. 43 44 options.iter: integer (optional) 45 Number of iterations. 46 47 Returns 48 ------- 49 iterator: Object 50 Iterator. 51 52 iterator.next(): Function 53 Returns an iterator protocol-compliant object containing the next 54 iterated value (if one exists) and a boolean flag indicating whether the 55 iterator is finished. 56 57 iterator.return( [value] ): Function 58 Finishes an iterator and returns a provided value. 59 60 iterator.PRNG: Function 61 Underlying pseudorandom number generator. 62 63 iterator.seed: any 64 Pseudorandom number generator seed. 65 66 iterator.seedLength: integer 67 Length of generator seed. 68 69 iterator.state: any 70 Generator state. 71 72 iterator.stateLength: integer 73 Length of generator state. 74 75 iterator.byteLength: integer 76 Size (in bytes) of generator state. 77 78 Examples 79 -------- 80 > var it = {{alias}}(); 81 > var r = it.next().value 82 <number> 83 > r = it.next().value 84 <number> 85 86 See Also 87 -------- 88