aboutsummaryrefslogtreecommitdiffstats
path: root/src/rqmc.hpp
diff options
context:
space:
mode:
authorBertrand <bertrand.horel@gmail.com>2016-04-12 17:05:23 +0000
committerBertrand <bertrand.horel@gmail.com>2016-04-12 17:05:23 +0000
commitbcafe5e41698c44b6aa77b8ef150f4224613c38f (patch)
tree0d2fcdd687970a7809f11c359c8c31aaf246c5ec /src/rqmc.hpp
parentbb87c9576a735fe9827db0d27d180b47f9884161 (diff)
downloadprojet_C++-bcafe5e41698c44b6aa77b8ef150f4224613c38f.tar.gz
rectification, renommage quasi_mean en monte_carlo, renommage quasi_option en quasi_mean qui est déplacée dans rqmc.hpp
Diffstat (limited to 'src/rqmc.hpp')
-rw-r--r--src/rqmc.hpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/rqmc.hpp b/src/rqmc.hpp
index 03f7e81..840e069 100644
--- a/src/rqmc.hpp
+++ b/src/rqmc.hpp
@@ -56,7 +56,7 @@ mean(int n, VA X){
//Les classes de monte-Carlo
template <typename L>
-std::vector<double> quasi_mean(int n, L X, double p=0.05)
+std::vector<double> monte_carlo(int n, L X, double p=0.05)
{
std::vector<double> result(3,0);
double x;
@@ -72,9 +72,9 @@ std::vector<double> quasi_mean(int n, L X, double p=0.05)
};
template <typename L, typename Fct>
-std::vector<double> quasi_mean(int n, Fct f, L X, double p=0.05)
+std::vector<double> monte_carlo(int n, Fct f, L X, double p=0.05)
{
- return quasi_mean(n, compose(f, X), p);
+ return monte_carlo(n, compose(f, X), p);
};
//Les classes de quasi-mean
@@ -120,6 +120,25 @@ struct gaussian_d : public var_alea<std::vector<double> >
gaussian G;
};
+template <typename Fct, typename LDS>
+struct quasi_mean : public generator<typename Fct::result_type>
+{
+ quasi_mean(int n, int d, Fct f) : n(n), d(d), f(f), G(d) {};
+
+ typename Fct::result_type operator()() {
+ double sum =0;
+ for(int i=0; i<n; i++){
+ sum += f(G());
+
+ }
+ return sum/n;
+ };
+
+ private:
+ int n, d;
+ Fct f;
+ quasi_gaussian<LDS> G;
+ };