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

Would someone who knows and cares about random numbers like to fix this bug in the Random library? Many thanks Simon -----Original Message----- From: glasgow-haskell-bugs-bounces@haskell.org [mailto:glasgow-haskell-bugs-bounces@haskell.org] On Behalf Of GHC Sent: 12 June 2006 23:28 To: glasgow-haskell-bugs@haskell.org 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@science.uva.nl | 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
participants (1)
-
Simon Peyton-Jones