mwc-random 0.13.4.0 → 0.13.5.0
raw patch · 6 files changed
+89/−69 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ System.Random.MWC.Distributions: logCategorical :: (PrimMonad m, Vector v Double) => v Double -> Gen (PrimState m) -> m Int
- System.Random.MWC.Distributions: uniformPermutation :: (PrimMonad m, Vector v Int) => Int -> Gen (PrimState m) -> m (v Int)
+ System.Random.MWC.Distributions: uniformPermutation :: forall m v. (PrimMonad m, Vector v Int) => Int -> Gen (PrimState m) -> m (v Int)
Files
- ChangeLog +0/−61
- System/Random/MWC.hs +3/−1
- System/Random/MWC/CondensedTable.hs +4/−3
- System/Random/MWC/Distributions.hs +15/−2
- changelog.md +65/−0
- mwc-random.cabal +2/−2
− ChangeLog
@@ -1,61 +0,0 @@-Changes in 0.13.4.0-- * withSystemRandom uses RtlGenRandom for seeding generator on windows---Changes in 0.13.3.1-- * primitive-0.6 compatibility---Changes in 0.13.3.0-- * Monadic variant of vector shuffle added: `uniformShuffleM`-- * Context on `uniformShuffle` loosened---Changes in 0.13.2.2-- * Fixed crash during gen. initialization on Windows when stderr- is not available (#36).--Changes in 0.13.2.0-- * Generators for beta, Bernoully, Dirichlet and categorical distributions- added.-- * Functions for generating random shuffles added.---Changes in 0.13.1.2-- * GHC 7.9 support---Changes in 0.13.1.1-- * Long standing performance problem in normal distribution fixed (#16)---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
@@ -310,7 +310,9 @@ v = fromIntegral y :: Int32 {-# INLINE wordsToDouble #-} --- | State of the pseudo-random number generator.+-- | State of the pseudo-random number generator. It uses mutable+-- state so same generator shouldn't be used from the different+-- threads simultaneously. newtype Gen s = Gen (M.MVector s Word32) -- | A shorter name for PRNG state in the 'IO' monad.
System/Random/MWC/CondensedTable.hs view
@@ -140,9 +140,10 @@ -- | Generate a condensed lookup table from integer weights. Weights--- should sum to @2^32@. If they don't, the algorithm will alter the--- weights so that they do. This approach should work reasonably well--- for rounding errors.+-- should sum to @2^32@ at least approximately. This function will+-- correct small deviations from @2^32@ such as arising from rounding+-- errors. But for large deviations it's likely to product incorrect+-- result with terrible performance. tableFromIntWeights :: (Vector v (a,Word32), Vector v a, Vector v Word32) => v (a, Word32) -> CondensedTable v a
System/Random/MWC/Distributions.hs view
@@ -23,6 +23,7 @@ , beta -- ** Discrete distribution , categorical+ , logCategorical , geometric0 , geometric1 , bernoulli@@ -63,8 +64,6 @@ -> Gen (PrimState m) -> m Double {-# INLINE normal #-}--- 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 = do x <- standard gen return $! m + s * x@@ -276,6 +275,20 @@ return $! case G.findIndex (>=p) cv of Just i -> i Nothing -> pkgError "categorical" "bad weights!"++-- | Random variate generator for categorical distribution where the+-- weights are in the log domain. It's implemented in terms of+-- 'categorical'.+logCategorical :: (PrimMonad m, G.Vector v Double)+ => v Double -- ^ List of logarithms of weights+ -> Gen (PrimState m) -- ^ Generator+ -> m Int+{-# INLINE logCategorical #-}+logCategorical v gen+ | G.null v = pkgError "logCategorical" "empty weights!"+ | otherwise = categorical (G.map (exp . subtract m) v) gen+ where+ m = G.maximum v -- | Random variate generator for uniformly distributed permutations. -- It returns random permutation of vector /[0 .. n-1]/.
+ changelog.md view
@@ -0,0 +1,65 @@+## Changes in 0.13.5.0++ * `logCategorical` added++## Changes in 0.13.4.0++ * `withSystemRandom` uses RtlGenRandom for seeding generator on windows+++## Changes in 0.13.3.1++ * primitive-0.6 compatibility+++## Changes in 0.13.3.0++ * Monadic variant of vector shuffle added: `uniformShuffleM`++ * Context on `uniformShuffle` loosened+++## Changes in 0.13.2.2++ * Fixed crash during gen. initialization on Windows when stderr+ is not available (#36).++## Changes in 0.13.2.0++ * Generators for beta, Bernoully, Dirichlet and categorical distributions+ added.++ * Functions for generating random shuffles added.+++## Changes in 0.13.1.2++ * GHC 7.9 support+++## Changes in 0.13.1.1++ * Long standing performance problem in normal distribution fixed (#16)+++## 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.
mwc-random.cabal view
@@ -1,5 +1,5 @@ name: mwc-random-version: 0.13.4.0+version: 0.13.5.0 synopsis: Fast, high quality pseudo random number generation description: This package contains code for generating high quality random@@ -26,7 +26,7 @@ build-type: Simple cabal-version: >= 1.8.0.4 extra-source-files:- ChangeLog+ changelog.md README.markdown benchmarks/*.hs benchmarks/Quickie.hs