Commits

Aleksey Khudyakov committed 53a0f26

Add logarithm of probability for discrete distributions

Comments (0)

Files changed (1)

Statistics/Distribution.hs

 class Distribution  d => DiscreteDistr d where
     -- | Probability of n-th outcome.
     probability :: d -> Int -> Double
+    probability d = exp . logProbability d
+    {-# INLINE probability #-}
+
+    -- | Logarithm of probability of n-th outcome
+    logProbability :: d -> Int -> Double
+    logProbability d = log . probability d
+    {-# INLINE logProbability #-}
 
 
 -- | Continuous probability distributuion.