summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2014-03-12 13:11:23 +0000
committerkr.angelov <kr.angelov@gmail.com>2014-03-12 13:11:23 +0000
commitebb61fbf1cf217d447f2d016b0e557e775c85271 (patch)
treee788370e12767f761dd2a36851fe2ec875f2eb47
parentf4be97c152d7613c0fcadc4183f916e705a9f986 (diff)
ensure that negative probabilities are always avoided
-rw-r--r--src/runtime/haskell/PGF/Probabilistic.hs2
1 files changed, 1 insertions, 1 deletions
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