Commits

Aleksey Khudyakov  committed fe79d5c

Add logDensity for gamma distr.

  • Participants
  • Parent commits 1a95b0d

Comments (0)

Files changed (1)

File Statistics/Distribution/Gamma.hs

 import Data.Binary (Binary)
 import Data.Data (Data, Typeable)
 import GHC.Generics (Generic)
-import Numeric.MathFunctions.Constants (m_pos_inf, m_NaN)
+import Numeric.MathFunctions.Constants (m_pos_inf, m_NaN, m_neg_inf)
 import Numeric.SpecFunctions (
   incompleteGamma, invIncompleteGamma, logGamma, digamma)
 import Statistics.Distribution.Poisson.Internal  as Poisson
 
 instance D.ContDistr GammaDistribution where
     density    = density
+    logDensity (GD k theta) x
+      | x <= 0    = m_neg_inf
+      | otherwise = log x * (k - 1) - (x / theta) - logGamma k - log theta * k
     quantile   = quantile
 
 instance D.Variance GammaDistribution where