module Gev ( Distribution(..) ) where
import System.Random.Stateful (StatefulGen, uniformDouble01M)
class Distribution d where
cdf :: d -> Double -> Double
cdf d
d Double
x = Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- d -> Double -> Double
forall d. Distribution d => d -> Double -> Double
complCdf d
d Double
x
complCdf :: d -> Double -> Double
complCdf d
d Double
x = Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- d -> Double -> Double
forall d. Distribution d => d -> Double -> Double
cdf d
d Double
x
pdf :: d -> Double -> Double
pdf d
d = Double -> Double
forall a. Floating a => a -> a
exp (Double -> Double) -> (Double -> Double) -> Double -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> Double -> Double
forall d. Distribution d => d -> Double -> Double
logPdf d
d
logPdf :: d -> Double -> Double
logPdf d
d = Double -> Double
forall a. Floating a => a -> a
log (Double -> Double) -> (Double -> Double) -> Double -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. d -> Double -> Double
forall d. Distribution d => d -> Double -> Double
pdf d
d
quantile :: d -> Double -> Double
quantile d
d Double
x = d -> Double -> Double
forall d. Distribution d => d -> Double -> Double
complQuantile d
d (Double
1Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
x)
complQuantile :: d -> Double -> Double
complQuantile d
d Double
x = d -> Double -> Double
forall d. Distribution d => d -> Double -> Double
quantile d
d (Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
x)
randGen :: StatefulGen g m => d -> g -> m Double
randGen d
d g
gen = do
Double
x <- g -> m Double
forall g (m :: * -> *). StatefulGen g m => g -> m Double
uniformDouble01M g
gen
Double -> m Double
forall (m :: * -> *) a. Monad m => a -> m a
return (Double -> m Double) -> Double -> m Double
forall a b. (a -> b) -> a -> b
$! d -> Double -> Double
forall d. Distribution d => d -> Double -> Double
quantile d
d Double
x
{-# MINIMAL (cdf | complCdf), (pdf | logPdf), (quantile | complQuantile) #-}