copulas library proposal

View: New views
3 Messages — Rating Filter:   Alert me  

copulas library proposal

by Marek2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Copulas might be useful as a part of math library and for some models
I attached proposal for:
ql/math/copulas/farliegumbelmorgensterncopula
ql/math/copulas/frankcopula
ql/math/copulas/gaussiancopula
ql/math/copulas/gumbelcopula
ql/math/copulas/independentcopula
ql/math/copulas/marshallolkincopula
ql/math/copulas/maxcopula
ql/math/copulas/mincopula

M.Glowacki
mglowacki100@...

p.s. Sorry for inconveniance, If I put this in wrong place, I'm quite new
to sourceforge and quantlib.
/* This file is automatically generated; do not edit.     */
/* Add the files to be included into Makefile.am instead. */


#include <ql/math/copulas/claytoncopula.hpp>
#include <ql/math/copulas/farliegumbelmorgensterncopula.hpp>
#include <ql/math/copulas/frankcopula.hpp>
#include <ql/math/copulas/gaussiancopula.hpp>
#include <ql/math/copulas/gumbelcopula.hpp>
#include <ql/math/copulas/independentcopula.hpp>
#include <ql/math/copulas/marshallolkincopula.hpp>
#include <ql/math/copulas/maxcopula.hpp>
#include <ql/math/copulas/mincopula.hpp>





[claytoncopula.cpp]

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/math/copulas/claytoncopula.hpp>

namespace QuantLib {

        ClaytonCopula::ClaytonCopula(Real theta): theta_(theta)
    {
        QL_REQUIRE(theta >= -1.0 && theta!=0, "theta should be greater or equal to -1 and different from 0");
    }
       

    Real ClaytonCopula::operator()(Real x, Real y) const
        {
        QL_REQUIRE( x >= 0.0 && x <=1 , "1st argument in [0,1] required");
                QL_REQUIRE( y >= 0.0 && y <=1 , "2nd argument in [0,1] required");
                using namespace std;

                return max( pow( pow(x,-theta_)+pow(y,-theta_)-1.0  , -1.0/theta_) , 0.0);
    }

}



/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file claytonopula.hpp
    \brief Clayton copula
*/

#ifndef quantlib_math_Clayton_copula_h
#define quantlib_math_Clayton_copula_h

#include <ql/errors.hpp>
#include <ql/types.hpp>
#include <functional>
#include <algorithm>

namespace QuantLib {

    class ClaytonCopula
        : public std::binary_function<Real,Real,Real> {
      public:
        ClaytonCopula(Real theta);
        Real operator()(Real x, Real y) const;
      private:
        Real theta_;
     
       
    };
   
   
}


#endif

[farliegumbelmorgensterncopula.cpp]

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/math/copulas/farliegumbelmorgensterncopula.hpp>

namespace QuantLib {

        FarlieGumbelMorgensternCopula::FarlieGumbelMorgensternCopula(Real theta): theta_(theta)
    {
        QL_REQUIRE(theta>=-1.0 && theta<= 1.00 , "theta should be in [-1,1]");
    }
       

    Real FarlieGumbelMorgensternCopula::operator()(Real x, Real y) const
        {
        QL_REQUIRE( x >= 0.0 && x <=1.0 , "1st argument in [0,1] required");
                QL_REQUIRE( y >= 0.0 && y <=1.0 , "2nd argument in [0,1] required");
                using namespace std;

                return x*y + theta_*x*y*(1.0 - x)*(1.0 - y);
    }

}



/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file farliegumbelmorgensterncopula.hpp
    \brief Farlie-Gumbel-Morgenstern copula
*/

#ifndef quantlib_math_Farlie_Gumbel_Morgenstern_copula_h
#define quantlib_math_Farlie_Gumbel_Morgenstern_copula_h

#include <ql/errors.hpp>
#include <ql/types.hpp>
#include <functional>
#include <algorithm>

namespace QuantLib {

    class FarlieGumbelMorgensternCopula
        : public std::binary_function<Real,Real,Real> {
      public:
        FarlieGumbelMorgensternCopula(Real theta);
        Real operator()(Real x, Real y) const;
      private:
        Real theta_;
       
    };
   
   
}


#endif

[frankcopula.cpp]

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/math/copulas/frankcopula.hpp>

namespace QuantLib {

        FrankCopula::FrankCopula(Real theta): theta_(theta)
    {
        QL_REQUIRE(theta != 0.0, "theta should not be 0");
    }
       

    Real FrankCopula::operator()(Real x, Real y) const
        {
        QL_REQUIRE( x >= 0.0 && x <=1.0 , "1st argument in [0,1] required");
                QL_REQUIRE( y >= 0.0 && y <=1.0 , "2nd argument in [0,1] required");
                using namespace std;

                return -1.0/theta_  *  log(1 + (exp(-theta_*x) -1) * (exp(-theta_*y) -1) / (exp(-theta_)- 1)   );
    }

}



/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file frankcopula.hpp
    \brief Frank copula
*/

#ifndef quantlib_math_Frank_copula_h
#define quantlib_math_Frank_copula_h

#include <ql/errors.hpp>
#include <ql/types.hpp>
#include <functional>
#include <algorithm>

namespace QuantLib {

    class FrankCopula
        : public std::binary_function<Real,Real,Real> {
      public:
        FrankCopula(Real theta);
        Real operator()(Real x, Real y) const;
      private:
        Real theta_;
     
       
    };
   
   
}


#endif

[gaussiancopula.cpp]

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/math/copulas/gaussiancopula.hpp>

#include <ql/math/distributions/bivariatenormaldistribution.hpp>
#include <ql/math/distributions/normaldistribution.hpp>
#include <iostream>

namespace QuantLib {

        GaussianCopula::GaussianCopula(Real rho): rho_(rho)
    {
        QL_REQUIRE(rho>=-1.0,
                   "rho must be >= -1.0 (" << rho << " not allowed)");
        QL_REQUIRE(rho<=1.0,
                   "rho must be <= 1.0 (" << rho << " not allowed)");
    }
       

    Real GaussianCopula::operator()(Real x, Real y) const
        {
        QL_REQUIRE( x >= 0.0 && x <=1 , "1st argument in [0,1] required");
                QL_REQUIRE( y >= 0.0 && y <=1 , "2nd argument in [0,1] required");


        BivariateCumulativeNormalDistributionWe04DP bivariate_normal_cdf(rho_);    
        InverseCumulativeNormal InvCumNormal;
        Real result = bivariate_normal_cdf(InvCumNormal(x),InvCumNormal(y));
       
        return result;
       
                               
    }

}



/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file gaussiancopula.hpp
    \brief gaussian copula
*/

#ifndef quantlib_math_gaussian_copula_h
#define quantlib_math_gaussian_copula_h

#include <ql/errors.hpp>
#include <ql/types.hpp>
#include <functional>
#include <algorithm>
#include <ql/math/distributions/bivariatenormaldistribution.hpp>
#include <ql/math/distributions/normaldistribution.hpp>


namespace QuantLib {

    class GaussianCopula
        : public std::binary_function<Real,Real,Real> {
      public:
        GaussianCopula(Real rho);
        Real operator()(Real x, Real y) const;
      private:
        Real rho_;
     
       
    };
   
   
}


#endif

[gumbelcopula.cpp]

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/math/copulas/gumbelcopula.hpp>

namespace QuantLib {

        GumbelCopula::GumbelCopula(Real theta): theta_(theta)
    {
        QL_REQUIRE(theta >= 1.0, "theta should be greater or equal to 1");
    }
       

    Real GumbelCopula::operator()(Real x, Real y) const
        {
        QL_REQUIRE( x >= 0.0 && x <=1.0 , "1st argument in [0,1] required");
                QL_REQUIRE( y >= 0.0 && y <=1.0 , "2nd argument in [0,1] required");
                using namespace std;

                return exp(-pow( pow( -log(x), theta_)+pow( -log(y), theta_),1/theta_));
    }

}



/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file gumbelcopula.hpp
    \brief Gumbel copula
*/

#ifndef quantlib_math_Gumbel_copula_h
#define quantlib_math_Gumbel_copula_h

#include <ql/errors.hpp>
#include <ql/types.hpp>
#include <functional>
#include <algorithm>
#include <cmath>

namespace QuantLib {

    class GumbelCopula
        : public std::binary_function<Real,Real,Real> {
      public:
        GumbelCopula(Real theta);
        Real operator()(Real x, Real y) const;
      private:
        Real theta_;
       
    };
   
   
}


#endif

[independentcopula.cpp]

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/math/copulas/independentcopula.hpp>

namespace QuantLib {

        IndependentCopula::IndependentCopula()
    {
    }
       

    Real IndependentCopula::operator()(Real x, Real y) const
        {
        QL_REQUIRE( x >= 0.0 && x <=1 , "1st argument in [0,1] required");
                QL_REQUIRE( y >= 0.0 && y <=1 , "2nd argument in [0,1] required");
               
                return x*y;
    }

}



/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file independentcopula.hpp
    \brief independent copula
*/

#ifndef quantlib_math_independent_copula_h
#define quantlib_math_independent_copula_h

#include <ql/errors.hpp>
#include <ql/types.hpp>
#include <functional>

namespace QuantLib {

    class IndependentCopula
        : public std::binary_function<Real,Real,Real> {
      public:
        IndependentCopula();
        Real operator()(Real x, Real y) const;
     
       
    };
   
   
}


#endif

[marshallolkincopula.cpp]

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/math/copulas/marshallolkincopula.hpp>

namespace QuantLib {

        MarshallOlkinCopula::MarshallOlkinCopula(Real a1,Real a2): a1_(a1),a2_(a2)
    {
        QL_REQUIRE(a1 >= 0.0, "1st parameter should greater or equal to 0");
        QL_REQUIRE(a2 >= 0.0, "2nd parameter should greater or equal to 0");
    }
       

    Real MarshallOlkinCopula::operator()(Real x, Real y) const
        {
        QL_REQUIRE( x >= 0.0 && x <=1.0 , "1st argument in [0,1] required");
                QL_REQUIRE( y >= 0.0 && y <=1.0 , "2nd argument in [0,1] required");
                using namespace std;

                return std::min(  pow(x,1.0-a1_)*y  ,  x*pow(y,1.0-a2_)  );
    }

}



/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file marshallolkincopula.hpp
    \brief Marshall-Olkin copula
*/

#ifndef quantlib_math_MarshallOlkin_copula_h
#define quantlib_math_MarshallOlkin_copula_h

#include <ql/errors.hpp>
#include <ql/types.hpp>
#include <functional>
#include <algorithm>

namespace QuantLib {

    class MarshallOlkinCopula
        : public std::binary_function<Real,Real,Real> {
      public:
        MarshallOlkinCopula(Real a1, Real a2);
        Real operator()(Real x, Real y) const;
      private:
        Real a1_;
        Real a2_;
       
    };
   
   
}


#endif

[maxcopula.cpp]

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/math/copulas/maxcopula.hpp>

namespace QuantLib {

        MaxCopula::MaxCopula()
    {
    }
       

    Real MaxCopula::operator()(Real x, Real y) const
        {
        QL_REQUIRE( x >= 0.0 && x <=1.0 , "1st argument in [0,1] required");
                QL_REQUIRE( y >= 0.0 && y <=1.0 , "2nd argument in [0,1] required");
               
                return std::min(x,y);
    }

}



/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file maxcopula.hpp
    \brief max copula
*/

#ifndef quantlib_math_max_copula_h
#define quantlib_math_max_copula_h

#include <ql/errors.hpp>
#include <ql/types.hpp>
#include <functional>
#include <algorithm>

namespace QuantLib {

    class MaxCopula
        : public std::binary_function<Real,Real,Real> {
      public:
        MaxCopula();
        Real operator()(Real x, Real y) const;
     
       
    };
   
   
}


#endif

[mincopula.cpp]

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/math/copulas/mincopula.hpp>

namespace QuantLib {

        MinCopula::MinCopula()
    {
    }
       

    Real MinCopula::operator()(Real x, Real y) const
        {
        QL_REQUIRE( x >= 0.0 && x <=1 , "1st argument in [0,1] required");
                QL_REQUIRE( y >= 0.0 && y <=1 , "2nd argument in [0,1] required");
                Real result=std::max(x+y-1.0, 0.0);
                return result;
    }

}



/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2008 Marek G³owacki

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@...>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file mincopula.hpp
    \brief min copula
*/

#ifndef quantlib_math_min_copula_h
#define quantlib_math_min_copula_h

#include <ql/errors.hpp>
#include <ql/types.hpp>
#include <functional>
#include <algorithm>

namespace QuantLib {

    class MinCopula
        : public std::binary_function<Real,Real,Real> {
      public:
        MinCopula();
        Real operator()(Real x, Real y) const;
     
       
    };
   
   
}


#endif

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
QuantLib-users mailing list
QuantLib-users@...
https://lists.sourceforge.net/lists/listinfo/quantlib-users

Re: copulas library proposal

by Luigi Ballabio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 2008-04-29 at 21:50 +0200, Marek Glowacki wrote:

> Copulas might be useful as a part of math library and for some models
> I attached proposal for:
> ql/math/copulas/farliegumbelmorgensterncopula
> ql/math/copulas/frankcopula
> ql/math/copulas/gaussiancopula
> ql/math/copulas/gumbelcopula
> ql/math/copulas/independentcopula
> ql/math/copulas/marshallolkincopula
> ql/math/copulas/maxcopula
> ql/math/copulas/mincopula

Marek,
        thanks for the contribution. I'm not sure that I'll have time to put it
in next release (I've already quite a few contribution to work on) but I
think it'll go into QuantLib eventually.

Later,
        Luigi


--

All generalizations are dangerous, even this one.
-- Alexandre Dumas



-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
QuantLib-users mailing list
QuantLib-users@...
https://lists.sourceforge.net/lists/listinfo/quantlib-users

Re: copulas library proposal

by Ferdinando Ametrano :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Marek

> Copulas might be useful as a part of math library and for some models
>  I attached proposal for:
>  ql/math/copulas/[...]

thanks for the contribution, I've just added it in the trunk code base.
I've pruned redundant inclusions, move inclusion to cpp file when
possible, expanded error messages to be more informative, and avoided
instantiating objects in the GaussianCopula::operator() method since
they could be instantiated once for all in the constructor.

It would be nice if you would contribute a unit test which reproduces
known tabulated values. This way I could have checked that I didn't
introduce any error ;-)

One question: you contributed bidimensional copulas. Is there an
efficient standard approach how to generalize to arbitrary dimensions?

>  Sorry for inconveniance, If I put this in wrong place, I'm quite new
>  to sourceforge and quantlib.
using the quantlib-dev mailing list would have been better, but I am
aware that the line between users and developers is blurred when it
comes to a C++ library.
You might want to reply only to the quantlib-dev address for further
discussions in this thread.

Thank you again

ciao -- Nando

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
QuantLib-users mailing list
QuantLib-users@...
https://lists.sourceforge.net/lists/listinfo/quantlib-users