packages feed

mwc-random 0.13.0.0 → 0.13.1.0

raw patch · 4 files changed

+51/−22 lines, 4 filesnew-uploader

Files

+ ChangeLog view
@@ -0,0 +1,19 @@+Changes in 0.13.1.0++  * createSystemRandom added++Changes in 0.13.0.0++  * Workaround for GHC bug 8072 (bug 25). GHC 7.6 on 32-bit platrofms is+    affected.++  * Generators for truncated exponential and geometric distributions+    added.++Changes in 0.12.0.0++  * Fucntion `asGenIO' and `asGenST' added.++  * Generation of discrete random variates using condensed tables+    methed. Tables for Poisson and binomial distributions are+    provided.
System/Random/MWC.hs view
@@ -37,7 +37,7 @@ -- The simplest use is to generate a vector of uniformly distributed values: -- -- @---   vs <- withSystemRandom . asGenST $ \gen -> uniformVector gen 100+--   vs \<- 'withSystemRandom' . 'asGenST' $ \\gen -> 'uniformVector' gen 100 -- @ -- -- These values can be of any type which is an instance of the class@@ -47,7 +47,7 @@ -- generator. -- -- @---   gen <- create+--   gen <- 'create' -- @ -- -- Hold onto this generator and use it wherever random values are@@ -56,11 +56,11 @@ -- away). Get a random value using 'uniform' or 'uniformR': -- -- @---   v <- uniform gen+--   v <- 'uniform' gen -- @ -- -- @---   v <- uniformR (1, 52) gen+--   v <- 'uniformR' (1, 52) gen -- @ module System.Random.MWC     (@@ -69,6 +69,7 @@     , create     , initialize     , withSystemRandom+    , createSystemRandom      -- ** Type helpers     -- $typehelp@@ -334,7 +335,7 @@ -- -- > initialize (singleton 42) ----- > initialize (toList [4, 8, 15, 16, 23, 42])+-- > initialize (fromList [4, 8, 15, 16, 23, 42]) -- -- If a seed contains fewer than 256 elements, it is first used -- verbatim, then its elements are 'xor'ed against elements of the@@ -440,6 +441,11 @@   where     warned = unsafePerformIO $ newIORef False     {-# NOINLINE warned #-}++-- | Seed a PRNG with data from the system's fast source of pseudo-random+-- numbers. All the caveats of 'withSystemRandom' apply here as well.+createSystemRandom :: IO GenIO+createSystemRandom = withSystemRandom (return :: GenIO -> IO GenIO)  -- | Compute the next index into the state pool.  This is simply -- addition modulo 256.
System/Random/MWC/Distributions.hs view
@@ -45,20 +45,9 @@        -> Gen (PrimState m)        -> m Double {-# INLINE normal #-}-normal m s gen = do-  x <- standard gen-  return $! m + s * x---- | Generate a normally distributed random variate with zero mean and--- unit variance.------ The implementation uses Doornik's modified ziggurat algorithm.--- Compared to the ziggurat algorithm usually used, this is slower,--- but generates more independent variates that pass stringent tests--- of randomness.-standard :: PrimMonad m => Gen (PrimState m) -> m Double-{-# INLINE standard #-}-standard gen = loop+-- We express standard in terms of normal and not other way round+-- because of bug in GHC. See bug #16 for more details.+normal m s gen = loop >>= (\x -> return $! m + s * x)   where     loop = do       u  <- (subtract 1 . (*2)) `liftM` uniform gen@@ -97,7 +86,18 @@                 then tailing                 else return $! if neg then x - r else r - x +-- | Generate a normally distributed random variate with zero mean and+-- unit variance.+--+-- The implementation uses Doornik's modified ziggurat algorithm.+-- Compared to the ziggurat algorithm usually used, this is slower,+-- but generates more independent variates that pass stringent tests+-- of randomness.+standard :: PrimMonad m => Gen (PrimState m) -> m Double+{-# INLINE standard #-}+standard = normal 0 1 + -- | Generate an exponentially distributed random variate. exponential :: PrimMonad m             => Double            -- ^ Scale parameter@@ -169,7 +169,8 @@                    return $! 2 * x  -- | Random variate generator for the geometric distribution,--- computing the number of failures before success. Supports [0..].+-- computing the number of failures before success. Distribution's+-- support is [0..]. geometric0 :: PrimMonad m            => Double            -- ^ /p/ success probability lies in (0,1]            -> Gen (PrimState m) -- ^ Generator@@ -184,7 +185,8 @@   | otherwise       = pkgError "geometric0" "probability out of [0,1] range"  -- | Random variate generator for geometric distribution for number of--- trials. Supports [1..] (i.e. just 'geometric0' shifted by 1).+-- trials. Distribution's support is [1..] (i.e. just 'geometric0'+-- shifted by 1). geometric1 :: PrimMonad m            => Double            -- ^ /p/ success probability lies in (0,1]            -> Gen (PrimState m) -- ^ Generator
mwc-random.cabal view
@@ -1,5 +1,5 @@ name:           mwc-random-version:        0.13.0.0+version:        0.13.1.0 synopsis:       Fast, high quality pseudo random number generation description:   This package contains code for generating high quality random@@ -14,6 +14,7 @@   Compared to the mersenne-random package, this package has a more   convenient API, is faster, and supports more statistical   distributions.+ license:        BSD3 license-file:   LICENSE homepage:       https://github.com/bos/mwc-random@@ -25,6 +26,7 @@ build-type:     Simple cabal-version:  >= 1.8 extra-source-files:+  ChangeLog   README.markdown   benchmarks/*.hs   benchmarks/Quickie.hs