{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module ELynx.Distribution.BirthDeathCriticalNoTime
( BirthDeathCriticalNoTimeDistribution (..),
cumulative,
density,
quantile,
)
where
import Data.Data
( Data,
Typeable,
)
import ELynx.Distribution.Types
import GHC.Generics (Generic)
import qualified Statistics.Distribution as D
newtype BirthDeathCriticalNoTimeDistribution = BDCNTD
{
bdcntdLa :: Rate
}
deriving (Eq, Typeable, Data, Generic)
instance D.Distribution BirthDeathCriticalNoTimeDistribution where
cumulative = cumulative
cumulative :: BirthDeathCriticalNoTimeDistribution -> Time -> Double
cumulative (BDCNTD l) x
| x <= 0 = 0
| otherwise = x * l / (1.0 + x * l)
instance D.ContDistr BirthDeathCriticalNoTimeDistribution where
density = density
quantile = quantile
density :: BirthDeathCriticalNoTimeDistribution -> Time -> Double
density (BDCNTD l) x
| x < 0 = 0
| otherwise = l / ((1.0 + x * l) ** 2)
quantile :: BirthDeathCriticalNoTimeDistribution -> Double -> Time
quantile (BDCNTD l) p
| p >= 0 && p <= 1 =
p / (l - l * p)
| otherwise =
error $ "PointProcess.quantile: p must be in [0,1]. Got: " ++ show p ++ "."
instance D.ContGen BirthDeathCriticalNoTimeDistribution where
genContVar = D.genContinuous