Skip to content
Browse files

Merge pull request #12 from npezolano/master

src/QuantLib/Math/ClaytonCopula.hs
  • Loading branch information...
2 parents 16d6063 + 3beb492 commit 4407958706509f55d33ac552c2567661ffd94001 @paulrzcz committed May 24, 2012
Showing with 24 additions and 0 deletions.
  1. +1 −0 src/QuantLib.hs
  2. +1 −0 src/QuantLib/Math.hs
  3. +22 −0 src/QuantLib/Math/ClaytonCopula.hs
View
1 src/QuantLib.hs
@@ -5,3 +5,4 @@ import QuantLib.Money as Q
import QuantLib.Position as Q
import QuantLib.TimeSeries as Q
import QuantLib.Prices as Q
+import QuantLib.Math as Q
View
1 src/QuantLib/Math.hs
@@ -3,3 +3,4 @@ module QuantLib.Math
) where
import QuantLib.Math.InverseNormal
+import QuantLib.Math.ClaytonCopula
View
22 src/QuantLib/Math/ClaytonCopula.hs
@@ -0,0 +1,22 @@
+
+{-| 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
+

0 comments on commit 4407958

Please sign in to comment.
Something went wrong with that request. Please try again.