25#ifndef quantlib_farlie_gumbel_morgenstern_copula_rng_hpp
26#define quantlib_farlie_gumbel_morgenstern_copula_rng_hpp
28#include <ql/methods/montecarlo/sample.hpp>
29#include <ql/errors.hpp>
50 const RNG& ug,
Real th)
51 : uniformGenerator_(ug), theta_(th) {
52 QL_REQUIRE(th >= -1.0 && th <= 1.00,
53 "theta (" << th <<
") must be in [-1,1]");
59 typename RNG::sample_type v1 = uniformGenerator_.next();
60 typename RNG::sample_type v2 = uniformGenerator_.next();
62 Real a = theta_*(2.0*u1-1.0);
63 Real b = pow(1.0-theta_*(2.0*u1-1.0),2.0)+4.0*theta_*v2.value*(2.0*u1-1.0);
64 Real u2 = (2.0*v2.value)/(sqrt(b)-a);
Farlie-Gumbel-Morgenstern copula random-number generator.
FarlieGumbelMorgensternCopulaRng(const RNG &uniformGenerator, Real theta)
Sample< std::vector< Real > > sample_type