repl.txt (8928B)
1 2 {{alias}}( p[, options] ) 3 Returns a readable stream for generating pseudorandom numbers drawn from a 4 Bernoulli distribution. 5 6 In addition to standard readable stream events, the returned stream emits a 7 'state' event after internally generating `siter` pseudorandom numbers, 8 which is useful when wanting to deterministically capture a stream's 9 underlying PRNG state. 10 11 Parameters 12 ---------- 13 p: number 14 Success probability. 15 16 options: Object (optional) 17 Options. 18 19 options.objectMode: boolean (optional) 20 Specifies whether a stream should operate in "objectMode". Default: 21 false. 22 23 options.encoding: string|null (optional) 24 Specifies how Buffer objects should be decoded to strings. Default: 25 null. 26 27 options.highWaterMark: integer (optional) 28 Specifies the maximum number of bytes to store in an internal buffer 29 before ceasing to generate additional pseudorandom numbers. 30 31 options.sep: string (optional) 32 Separator used to join streamed data. This option is only applicable 33 when a stream is not in "objectMode". Default: '\n'. 34 35 options.iter: integer (optional) 36 Number of iterations. 37 38 options.prng: Function (optional) 39 Pseudorandom number generator (PRNG) for generating uniformly 40 distributed pseudorandom numbers on the interval `[0,1)`. If provided, 41 the `state` and `seed` options are ignored. In order to seed the 42 returned iterator, one must seed the provided `prng` (assuming the 43 provided `prng` is seedable). 44 45 options.seed: integer|ArrayLikeObject<integer> (optional) 46 Pseudorandom number generator seed. The seed may be either a positive 47 unsigned 32-bit integer or, for arbitrary length seeds, an array-like 48 object containing unsigned 32-bit integers. 49 50 options.state: Uint32Array (optional) 51 Pseudorandom number generator state. If provided, the `seed` option is 52 ignored. 53 54 options.copy: boolean (optional) 55 Boolean indicating whether to copy a provided pseudorandom number 56 generator state. Setting this option to `false` allows sharing state 57 between two or more pseudorandom number generators. Setting this option 58 to `true` ensures that a returned iterator has exclusive control over 59 its internal state. Default: true. 60 61 options.siter: integer (optional) 62 Number of iterations after which to emit the PRNG state. Default: 1e308. 63 64 Returns 65 ------- 66 stream: ReadableStream 67 Readable stream. 68 69 stream.PRNG: Function 70 Underlying pseudorandom number generator. 71 72 stream.seed: Uint32Array|null 73 Pseudorandom number generator seed. 74 75 stream.seedLength: integer|null 76 Length of generator seed. 77 78 stream.state: Uint32Array|null 79 Generator state. 80 81 stream.stateLength: integer|null 82 Length of generator state. 83 84 stream.byteLength: integer|null 85 Size (in bytes) of generator state. 86 87 Examples 88 -------- 89 > function fcn( chunk ) { console.log( chunk.toString() ); }; 90 > var opts = { 'iter': 10 }; 91 > var s = {{alias}}( 0.5, opts ); 92 > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); 93 > s.pipe( o ); 94 95 96 {{alias}}.factory( [p, ][options] ) 97 Returns a function for creating readable streams which generate pseudorandom 98 numbers drawn from a Bernoulli distribution. 99 100 If provided distribution parameters, the returned function returns readable 101 streams which generate pseudorandom numbers drawn from the specified 102 distribution. 103 104 If not provided distribution parameters, the returned function requires that 105 distribution parameters be provided at each invocation. 106 107 Parameters 108 ---------- 109 p: number (optional) 110 Success probability. 111 112 options: Object (optional) 113 Options. 114 115 options.objectMode: boolean (optional) 116 Specifies whether a stream should operate in "objectMode". Default: 117 false. 118 119 options.encoding: string|null (optional) 120 Specifies how Buffer objects should be decoded to strings. Default: 121 null. 122 123 options.highWaterMark: integer (optional) 124 Specifies the maximum number of bytes to store in an internal buffer 125 before ceasing to generate additional pseudorandom numbers. 126 127 options.sep: string (optional) 128 Separator used to join streamed data. This option is only applicable 129 when a stream is not in "objectMode". Default: '\n'. 130 131 options.iter: integer (optional) 132 Number of iterations. 133 134 options.prng: Function (optional) 135 Pseudorandom number generator (PRNG) for generating uniformly 136 distributed pseudorandom numbers on the interval `[0,1)`. If provided, 137 the `state` and `seed` options are ignored. In order to seed the 138 returned iterator, one must seed the provided `prng` (assuming the 139 provided `prng` is seedable). 140 141 options.seed: integer|ArrayLikeObject<integer> (optional) 142 Pseudorandom number generator seed. The seed may be either a positive 143 unsigned 32-bit integer or, for arbitrary length seeds, an array-like 144 object containing unsigned 32-bit integers. 145 146 options.state: Uint32Array (optional) 147 Pseudorandom number generator state. If provided, the `seed` option is 148 ignored. 149 150 options.copy: boolean (optional) 151 Boolean indicating whether to copy a provided pseudorandom number 152 generator state. Setting this option to `false` allows sharing state 153 between two or more pseudorandom number generators. Setting this option 154 to `true` ensures that a returned iterator has exclusive control over 155 its internal state. Default: true. 156 157 options.siter: integer (optional) 158 Number of iterations after which to emit the PRNG state. Default: 1e308. 159 160 Returns 161 ------- 162 fcn: Function 163 Function for creating readable streams. 164 165 Examples 166 -------- 167 > var opts = { 'objectMode': true, 'highWaterMark': 64 }; 168 > var createStream = {{alias}}.factory( opts ); 169 170 171 {{alias}}.objectMode( p[, options] ) 172 Returns an "objectMode" readable stream for generating pseudorandom numbers 173 drawn from a Bernoulli distribution. 174 175 Parameters 176 ---------- 177 p: number 178 Success probability. 179 180 options: Object (optional) 181 Options. 182 183 options.encoding: string|null (optional) 184 Specifies how Buffer objects should be decoded to strings. Default: 185 null. 186 187 options.highWaterMark: integer (optional) 188 Specifies the maximum number of objects to store in an internal buffer 189 before ceasing to generate additional pseudorandom numbers. 190 191 options.iter: integer (optional) 192 Number of iterations. 193 194 options.prng: Function (optional) 195 Pseudorandom number generator (PRNG) for generating uniformly 196 distributed pseudorandom numbers on the interval `[0,1)`. If provided, 197 the `state` and `seed` options are ignored. In order to seed the 198 returned iterator, one must seed the provided `prng` (assuming the 199 provided `prng` is seedable). 200 201 options.seed: integer|ArrayLikeObject<integer> (optional) 202 Pseudorandom number generator seed. The seed may be either a positive 203 unsigned 32-bit integer or, for arbitrary length seeds, an array-like 204 object containing unsigned 32-bit integers. 205 206 options.state: Uint32Array (optional) 207 Pseudorandom number generator state. If provided, the `seed` option is 208 ignored. 209 210 options.copy: boolean (optional) 211 Boolean indicating whether to copy a provided pseudorandom number 212 generator state. Setting this option to `false` allows sharing state 213 between two or more pseudorandom number generators. Setting this option 214 to `true` ensures that a returned iterator has exclusive control over 215 its internal state. Default: true. 216 217 options.siter: integer (optional) 218 Number of iterations after which to emit the PRNG state. Default: 1e308. 219 220 Returns 221 ------- 222 stream: ReadableStream 223 Readable stream operating in "objectMode". 224 225 stream.PRNG: Function 226 Underlying pseudorandom number generator. 227 228 stream.seed: Uint32Array|null 229 Pseudorandom number generator seed. 230 231 stream.seedLength: integer|null 232 Length of generator seed. 233 234 stream.state: Uint32Array|null 235 Generator state. 236 237 stream.stateLength: integer|null 238 Length of generator state. 239 240 stream.byteLength: integer|null 241 Size (in bytes) of generator state. 242 243 Examples 244 -------- 245 > function fcn( v ) { console.log( v ); }; 246 > var opts = { 'iter': 10 }; 247 > var s = {{alias}}.objectMode( 0.3, opts ); 248 > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); 249 > s.pipe( o ); 250 251 See Also 252 -------- 253