System.Random: StdGen's genRange doesn't match its next
> g <- getStdGen
> length $ filter (<0) $ take (10^6) $ unfoldr (Just . next) g
0
> genRange g
(-2147483648,2147483647)
Apparently, StdGen
's next
only returns non-negative values.
Also, StdGen
doesn't override de default method genRange
. However, the System.Random docs (http://haskell.org/ghc/docs/latest/html/libraries/base/System-Random.html#v%3Anext) promise:
The next operation returns an Int that is uniformly distributed in the range returned by genRange (including both end points), and a new generator.
Thus, StdGen
's next
violates the uniform distribution requirement.
Trac metadata
Trac field | Value |
---|---|
Version | 6.4.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |