packages feed

MonadRandom 0.1.12 → 0.1.13

raw patch · 3 files changed

+12/−1 lines, 3 files

Files

CHANGES.markdown view
@@ -1,3 +1,9 @@+0.1.13 (9 February 2014)+------------------------++  - add simple 'uniform' function for creating a uniform distribution+    over a list of values+ 0.1.12 (30 September 2013) -------------------------- 
Control/Monad/Random.hs view
@@ -36,6 +36,7 @@     runRand,     evalRandIO,     fromList,+    uniform,     Rand, RandT, -- but not the data constructors     -- * Special lift functions     liftRand,@@ -138,6 +139,10 @@       cs = scanl1 (\(_,q) (y,s') -> (y, s'+q)) xs       -- cumulative weight   p <- liftM toRational $ getRandomR (0.0,s)   return . fst . head $ dropWhile (\(_,q) -> q < p) cs++-- | Sample a value from a uniform distribution of a list of elements.+uniform :: (MonadRandom m) => [a] -> m a+uniform = fromList . fmap (flip (,) 1)  instance (MonadRandom m) => MonadRandom (IdentityT m) where     getRandom = lift getRandom
MonadRandom.cabal view
@@ -1,5 +1,5 @@ name:                MonadRandom-version:             0.1.12+version:             0.1.13 synopsis:            Random-number generation monad. description:         Support for computations which consume random values. license:             OtherLicense