From ebb61fbf1cf217d447f2d016b0e557e775c85271 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Wed, 12 Mar 2014 13:11:23 +0000 Subject: [PATCH] ensure that negative probabilities are always avoided --- src/runtime/haskell/PGF/Probabilistic.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/haskell/PGF/Probabilistic.hs b/src/runtime/haskell/PGF/Probabilistic.hs index 095ade022..7d8d58134 100644 --- a/src/runtime/haskell/PGF/Probabilistic.hs +++ b/src/runtime/haskell/PGF/Probabilistic.hs @@ -68,7 +68,7 @@ mkProbabilities pgf probs = where deflt = case length [f | (Nothing,f) <- pfs] of 0 -> 0 - n -> (1 - sum [d | (Just d,f) <- pfs]) / fromIntegral n + n -> max 0 ((1 - sum [d | (Just d,f) <- pfs]) / fromIntegral n) -- | Returns the default even distibution. defaultProbabilities :: PGF -> Probabilities