paulrzcz/hquantlib — pull request #12 by npezolano (2012-05-24 17:47:27+00:00)
Title: src/QuantLib/Math/ClaytonCopula.hs

{-| Original code and algorithm from the Quantlib project
implemented in Haskell by Nicholas Pezolano
npezolano "at" gmail.com
-}

module QuantLib.Math.ClaytonCopula
( claytonCopula
) where

claytonCopula :: Double -> Double -> Double -> Maybe Double
claytonCopula x y theta
| x >= 0.0
|| x <= 1.0
|| y >= 0.0
|| y <=1.0
|| theta /=0
|| theta >= -1.0
= Nothing

| otherwise
= Just $ max( (x ** (-theta) ) + (y ** (-theta)-1.0) ** (-1.0/theta)) 0