sampling

Basic sampling functionality for Haskell.
Log | Files | Refs | README | LICENSE

commit 5d7aa64cca741d429c0dd95caac3f8c99146336a
parent 2f700f4f961072b00517b0139be81ff74162731e
Author: Jared Tobin <jared@jtobin.ca>
Date:   Tue, 17 Apr 2018 11:13:43 +1200

Minor tweaks.

* Don't create a new PRNG every time for IO-specialized things.
* Relax upper bound to support newer base versions.
* v0.3.2 -> v0.3.3

Diffstat:
Mlib/Numeric/Sampling.hs | 8++------
Msampling.cabal | 4++--
2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/lib/Numeric/Sampling.hs b/lib/Numeric/Sampling.hs @@ -55,9 +55,7 @@ sample n xs gen -- | (/O(n)/) 'sample' specialized to IO. sampleIO :: Foldable f => Int -> f a -> IO (Maybe [a]) -sampleIO n xs = do - gen <- createSystemRandom - sample n xs gen +sampleIO n xs = withSystemRandom . asGenIO $ sample n xs {-# INLINABLE sampleIO #-} -- | (/O(n log n)/) Sample uniformly with replacement (bootstrap). @@ -71,9 +69,7 @@ resample n xs = presample n weighted where -- | (/O(n log n)/) 'resample' specialized to IO. resampleIO :: Foldable f => Int -> f a -> IO [a] -resampleIO n xs = do - gen <- createSystemRandom - resample n xs gen +resampleIO n xs = withSystemRandom . asGenIO $ resample n xs {-# INLINABLE resampleIO #-} -- | (/O(n log n)/) Unequal probability sampling. diff --git a/sampling.cabal b/sampling.cabal @@ -1,5 +1,5 @@ name: sampling -version: 0.3.2 +version: 0.3.3 synopsis: Sample values from collections. homepage: https://github.com/jtobin/sampling license: MIT @@ -36,7 +36,7 @@ library exposed-modules: Numeric.Sampling build-depends: - base > 4.8 && < 5 + base > 4.8 && < 6 , containers >= 0.5 && < 1 , foldl >= 1.1 && < 2 , mwc-random >= 0.13 && < 0.14