2020 */
2121#include " otvine/VineCopulaFactory.hxx"
2222#include < openturns/PersistentObjectFactory.hxx>
23+ #include < openturns/ClaytonCopula.hxx>
24+ #include < openturns/GumbelCopula.hxx>
25+ #include < openturns/FrankCopula.hxx>
2326
2427#include < vinecopulib.hpp>
2528
@@ -47,7 +50,7 @@ VineCopulaFactory * VineCopulaFactory::clone() const
4750}
4851
4952/* example of a func that return a point squared. */
50- VineCopula VineCopulaFactory::buildAsNative (const Sample & sample) const
53+ Distribution VineCopulaFactory::build (const Sample & sample) const
5154{
5255 const UnsignedInteger dimension = sample.getDimension ();
5356 const UnsignedInteger size = sample.getSize ();
@@ -57,21 +60,36 @@ VineCopula VineCopulaFactory::buildAsNative(const Sample & sample) const
5760 data (i, j) = sample (i, j);
5861 Pointer <vinecopulib::Vinecop> p_vinecop = new vinecopulib::Vinecop (dimension);
5962 std::vector<vinecopulib::BicopFamily> family_set;
60- #if 1
63+ #if 0
6164 family_set = {
6265 vinecopulib::BicopFamily::clayton,
6366 vinecopulib::BicopFamily::gumbel,
6467 vinecopulib::BicopFamily::frank};
6568#endif
6669 vinecopulib::FitControlsVinecop controls (family_set);
6770 p_vinecop->select (data, controls);
71+
72+ #if 0
73+ std::vector<std::vector<vinecopulib::Bicop> > pairs = p_vinecop->get_all_pair_copulas();
74+ if (p_vinecop->get_dim() == 2 && pairs.size() == 1 && pairs[0].size() == 1)
75+ {
76+ vinecopulib::Bicop bicop = pairs[0][0];
77+ int rotation = bicop.get_rotation();
78+ if (rotation == 0)
79+ {
80+ const Scalar theta = bicop.get_parameters()(0, 0);
81+ if (bicop.get_family_name() == "Clayton")
82+ return ClaytonCopula(theta);
83+ else if (bicop.get_family_name() == "Frank")
84+ return FrankCopula(theta);
85+ else if (bicop.get_family_name() == "Gumbel")
86+ return GumbelCopula(theta);
87+ }
88+ }
89+ #endif
6890 return VineCopula (p_vinecop);
6991}
7092
71- Distribution VineCopulaFactory::build (const Sample & sample) const
72- {
73- return buildAsNative (sample);
74- }
7593
7694/* String converter */
7795String VineCopulaFactory::__repr__ () const
0 commit comments