logo       

[GHC] #794: System.Random: StdGen's genRange doesn't match its next: msg#00058

lang.haskell.glasgow.bugs

Subject: [GHC] #794: System.Random: StdGen's genRange doesn't match its next

#794: System.Random: StdGen's genRange doesn't match its next
-------------------------------------+--------------------------------------
Reporter: rturk@xxxxxxxxxxxxxx | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: libraries/base | Version: 6.4.2
Severity: normal | Keywords:
Os: Unknown | Difficulty: Easy (1 hr)
Architecture: Unknown |
-------------------------------------+--------------------------------------
{{{
> 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.

--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/794>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise