aboutsummaryrefslogtreecommitdiff
path: root/src/PPL/Sampling.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/PPL/Sampling.hs')
-rw-r--r--src/PPL/Sampling.hs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/PPL/Sampling.hs b/src/PPL/Sampling.hs
index 256e67b..8a74854 100644
--- a/src/PPL/Sampling.hs
+++ b/src/PPL/Sampling.hs
@@ -15,7 +15,6 @@ import Control.Monad.IO.Class
import Data.IORef
import Data.Vector qualified as V
import Data.Vector.Hashtables qualified as H
-import Data.Word
import Numeric.Log
import PPL.Internal
import Streaming.Prelude (Of, Stream, yield)
@@ -49,5 +48,5 @@ mh g p m = do
ks <- H.keys m
let (rs, qs) = splitAt (1 + floor (p * (n - 1))) (R.randoms g)
n = fromIntegral (V.length ks)
- void $ zipWithM (\r q -> H.insert m' (ks V.! floor (r * n)) q) rs qs
+ when (n > 0) $ void $ zipWithM (\r q -> H.insert m' (ks V.! floor (r * n)) q) rs qs
newIORef (m', g0)