From 045fc28b3432e07f3d9702150a56f21e7650f12a Mon Sep 17 00:00:00 2001 From: Bertrand Date: Sun, 21 Feb 2016 14:26:26 +0000 Subject: modif du Makefile et de var_alea et autres --- src/stratified_sampling.hpp | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'src/stratified_sampling.hpp') diff --git a/src/stratified_sampling.hpp b/src/stratified_sampling.hpp index 81080fc..cebee8d 100644 --- a/src/stratified_sampling.hpp +++ b/src/stratified_sampling.hpp @@ -3,20 +3,11 @@ #include #include #include "rtnorm.hpp" +#include "var_alea.hpp" +#include using namespace std; -template -struct var_alea { - typedef T result_type; - var_alea() : value(0) {}; - var_alea(T value) : value(value) {}; - virtual ~var_alea() {}; - virtual T operator()() = 0; - T current() const { return value; }; -protected: - T value; -}; typedef var_alea var_alea_real; @@ -45,6 +36,37 @@ private: gsl_rng *gen; }; +struct multi_gaussian_truncated : public var_alea > +{ + multi_gaussian_truncated(double a, double b, const std::vector u) + :a(a), b(b), V(gsl_cdf_ugaussian_P(a), gsl_cdf_ugaussian_P(b)), G(0,1), u(u), d(u.size()) {}; + + std::vector operator()() { + double v = V(); + double Z = gsl_cdf_gaussian_Pinv(v,1); + std::vector Y(d); + double scal = 0; + for(int i=0; i X(d); + for(int j=0; j u; + int d; + }; + template struct stratified_sampling { stratified_sampling(vector p, vector X) -- cgit v1.2.3-70-g09d2