module Statistics.Odds where
import Control.DeepSeq (NFData(..))
import Data.Aeson (FromJSON,ToJSON)
import Data.Binary (Binary)
import Data.Hashable (Hashable)
import Data.Serialize (Serialize)
import Data.Vector.Unboxed.Deriving
import GHC.Generics (Generic)
import Algebra.Structure.Semiring
import Numeric.Discretized
import Numeric.Limits
newtype Odds = Odds { getOdds ∷ Double }
deriving (Generic,Eq,Ord,Show,Read,Num)
deriving instance Semiring Odds
newtype DiscLogOdds (t∷k) = DiscLogOdds { getDiscLogOdds ∷ Discretized t }
deriving (Generic,Eq,Ord,Show,Read)
deriving instance (Num (Discretized (t∷k))) ⇒ Num (DiscLogOdds t)
deriving instance (Semiring (Discretized (t∷k))) ⇒ Semiring (DiscLogOdds t)
derivingUnbox "DiscretizedLogOdds"
[t| forall t . DiscLogOdds t → Int |] [| getDiscretized . getDiscLogOdds |] [| DiscLogOdds . Discretized |]
instance Binary (DiscLogOdds t)
instance Serialize (DiscLogOdds t)
instance FromJSON (DiscLogOdds t)
instance ToJSON (DiscLogOdds t)
instance Hashable (DiscLogOdds t)
instance (NFData (Discretized t)) ⇒ NFData (DiscLogOdds t) where
rnf (DiscLogOdds k) = rnf k
{-# Inline rnf #-}
instance (NumericLimits (Discretized t)) ⇒ NumericLimits (DiscLogOdds t) where
minFinite = DiscLogOdds minFinite
{-# Inline minFinite #-}
maxFinite = DiscLogOdds maxFinite
{-# Inline maxFinite #-}