| 23 | } |
| 24 | |
| 25 | function rbits(bits: number, unif_rand: IRNG) { |
| 26 | let v = 0n; |
| 27 | |
| 28 | for (let n = 0; n <= bits; n += 16) { |
| 29 | // FIXME: should this not be "*65535" ?, its ok, 65534 would be an error!!! (as some part of the range would not be reachable) |
| 30 | // but 65536 not matter so much |
| 31 | const ran = unif_rand.random(); |
| 32 | const v1 = new Int32Array([trunc(ran * 65536)]); |
| 33 | v = 65536n * v + BigInt(v1[0]); // |
| 34 | } |
| 35 | // mask out the bits in the result that are not needed |
| 36 | return v & ((1n << BigInt(bits)) - 1n); |
| 37 | } |
| 38 | |
| 39 | function R_unif_index_0(dn: number, unif_rand: IRNG): number { |
| 40 | const cut = unif_rand.cut; |