{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances, FlexibleContexts #-} module Data.Random.Distribution.Weibull where import Data.Random.Distribution import Data.Random.Distribution.Uniform data Weibull a = Weibull { forall a. Weibull a -> a weibullLambda :: !a, forall a. Weibull a -> a weibullK :: !a } deriving (Weibull a -> Weibull a -> Bool forall a. Eq a => Weibull a -> Weibull a -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Weibull a -> Weibull a -> Bool $c/= :: forall a. Eq a => Weibull a -> Weibull a -> Bool == :: Weibull a -> Weibull a -> Bool $c== :: forall a. Eq a => Weibull a -> Weibull a -> Bool Eq, Int -> Weibull a -> ShowS forall a. Show a => Int -> Weibull a -> ShowS forall a. Show a => [Weibull a] -> ShowS forall a. Show a => Weibull a -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Weibull a] -> ShowS $cshowList :: forall a. Show a => [Weibull a] -> ShowS show :: Weibull a -> String $cshow :: forall a. Show a => Weibull a -> String showsPrec :: Int -> Weibull a -> ShowS $cshowsPrec :: forall a. Show a => Int -> Weibull a -> ShowS Show) instance (Floating a, Distribution StdUniform a) => Distribution Weibull a where rvarT :: forall (n :: * -> *). Weibull a -> RVarT n a rvarT (Weibull a lambda a k) = do a u <- forall (d :: * -> *) t (n :: * -> *). Distribution d t => d t -> RVarT n t rvarT forall t. StdUniform t StdUniform forall (m :: * -> *) a. Monad m => a -> m a return (a lambda forall a. Num a => a -> a -> a * (forall a. Num a => a -> a negate (forall a. Floating a => a -> a log a u)) forall a. Floating a => a -> a -> a ** forall a. Fractional a => a -> a recip a k) instance (Real a, Distribution Weibull a) => CDF Weibull a where cdf :: Weibull a -> a -> Double cdf (Weibull a lambda a k) a x = Double 1 forall a. Num a => a -> a -> a - forall a. Floating a => a -> a exp (forall a. Num a => a -> a negate ((forall a b. (Real a, Fractional b) => a -> b realToFrac a x forall a. Fractional a => a -> a -> a / forall a b. (Real a, Fractional b) => a -> b realToFrac a lambda) forall a. Floating a => a -> a -> a ** forall a b. (Real a, Fractional b) => a -> b realToFrac a k))