Attached file `randpatch`

(download).

new randomIvalInteger patch

It ran overnight and I forgot to use `time`

, so I'm not sure. Running with 20 billion iterations took 36 minutes on my linode, though, so I would expect it took about 6 hours.

I just now reran this tool looking for `v == 3`

and it output `Just 871055575`

, which is reasonable.

`genRange`

for `StdGen`

returns `(0,2147483562)`

. However, as far as I can tell, `StdGen`

doesn't generate 0.

This code performs 200 billion iterations of `next`

on a `StdGen`

. I ran it and it output `Nothing`

. The probability that no 0 was generated by chance is approximately *e^-200/2.147^* =~ *10^-40^*.

` import System.Random import Data.Int

find0 :: StdGen -> Int64 -> Maybe Int64 find0 g0 n0 = aux g0 n0 where aux _ 0 = Nothing aux g r = let (v,g') = next g in if v == 0 then Just (n0 - r + 1) else aux g' (r-1)

main :: IO () main = print $ find0 (mkStdGen 1234) 200000000000 `

Trac field | Value |
---|---|

Version | 7.9 |

Type | Bug |

TypeOfFailure | OtherFailure |

Priority | normal |

Resolution | Unresolved |

Component | libraries/random |

Test case | |

Differential revisions | |

BlockedBy | |

Related | |

Blocking | |

CC | |

Operating system | |

Architecture |

The login link did something to let me change my login.

The error still exists because I can click on logout and login and I am not prompted for a password. However, my problem is worked around for now.

I had been using Firefox. I tried Chrome and I got the verification email.

I still can't log in with Firefox. It keeps sending me to guest.

The current `randomIvalInteger`

implementation uses repeated `div`

operations to approximate the size of the desired random output, then generates that number of random values from the given `RandomGen`

. It does not compensate for the ``mod` base`

uniformity problem. It also assumes that all `RandomGen` implementations produce the same range of random values as `StdGen`.

My new implementation addresses all these correctness issues, with potentially a slight performance improvement.

Instead of performing repeated div base operations to determine the size of the desired range, this uses faster `(* base)`

operations. An equivalent set of intermediate `Integer`

s is generated still.

To compensate for the ``mod` base`

uniformity problem, the desired range size is multiplied by the *q* factor (1000 in my code). When *k* is the desired range and *b^n^* is the range of numbers generated, and *d = b^n^ div k*, some elements will have probability *d/b^n^* and others will have probability *(d+1)/b^n^*, resulting in significant non-uniformity when *d* is very small. When you extend the generated range beyond the minimum by a factor of *q*, you are guaranteed that *d* will be at least *q*, so the non-uniformity will be much less consequential.

This implementation also works with any `RandomGen`

, even ones that produce as little as a single bit of entropy per next call or have a minimum bound other than zero.

I mistyped my Full Name when I registered my account. I try to change it from preferences and I get an error message "Warning: The email address specified is already in use. Please specify a different one."

Trac field | Value |
---|---|

Version | 7.6.3 |

Type | Bug |

TypeOfFailure | OtherFailure |

Priority | normal |

Resolution | Unresolved |

Component | Trac & Git |

Test case | |

Differential revisions | |

BlockedBy | |

Related | |

Blocking | |

CC | |

Operating system | |

Architecture |