1. Bryan O'Sullivan
  2. statistics

Commits

Aleksey Khudyakov  committed 53a0f26

Add logarithm of probability for discrete distributions

  • Participants
  • Parent commits a03dcdc
  • Branches default

Comments (0)

Files changed (1)

File Statistics/Distribution.hs

View file
  • Ignore whitespace
 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.