diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2014-03-12 13:11:23 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2014-03-12 13:11:23 +0000 |
| commit | ebb61fbf1cf217d447f2d016b0e557e775c85271 (patch) | |
| tree | e788370e12767f761dd2a36851fe2ec875f2eb47 /src/runtime | |
| parent | f4be97c152d7613c0fcadc4183f916e705a9f986 (diff) | |
ensure that negative probabilities are always avoided
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/haskell/PGF/Probabilistic.hs | 2 |
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 |
