| 119235 | }; |
| 119236 | } |
| 119237 | function integer(min, max) { |
| 119238 | if (max == null) { |
| 119239 | max = min; |
| 119240 | min = 0; |
| 119241 | } |
| 119242 | let a, b, d; |
| 119243 | const dist = { |
| 119244 | min (_) { |
| 119245 | if (arguments.length) { |
| 119246 | a = _ || 0; |
| 119247 | d = b - a; |
| 119248 | return dist; |
| 119249 | } else return a; |
| 119250 | }, |
| 119251 | max (_) { |
| 119252 | if (arguments.length) { |
| 119253 | b = _ || 0; |
| 119254 | d = b - a; |
| 119255 | return dist; |
| 119256 | } else return b; |
| 119257 | }, |
| 119258 | sample () { |
| 119259 | return a + Math.floor(d * random()); |
| 119260 | }, |
| 119261 | pdf (x) { |
| 119262 | return x === Math.floor(x) && x >= a && x < b ? 1 / d : 0; |
| 119263 | }, |
| 119264 | cdf (x) { |
| 119265 | const v = Math.floor(x); |
| 119266 | return v < a ? 0 : v >= b ? 1 : (v - a + 1) / d; |
| 119267 | }, |
| 119268 | icdf (p) { |
| 119269 | return p >= 0 && p <= 1 ? a - 1 + Math.floor(p * d) : NaN; |
| 119270 | } |
| 119271 | }; |
| 119272 | return dist.min(min).max(max); |
| 119273 | } |
| 119274 | const SQRT2PI = Math.sqrt(2 * Math.PI); |
| 119275 | const SQRT2 = Math.SQRT2; |
| 119276 | let nextSample = NaN; |