aboutsummaryrefslogtreecommitdiffstats
path: root/rqmc.hpp
diff options
context:
space:
mode:
authorBertrand <bertrand.horel@gmail.com>2016-02-16 22:01:28 +0000
committerBertrand <bertrand.horel@gmail.com>2016-02-16 22:01:28 +0000
commit6b07d76c512c5450ce34fd6f2f8483c395a24ea2 (patch)
tree88583472c85eaae00d25435ef03da7e1fd7493b3 /rqmc.hpp
parentcee0800329a0be3b27ae3907498ddf0883393382 (diff)
downloadprojet_C++-6b07d76c512c5450ce34fd6f2f8483c395a24ea2.tar.gz
meilleur encapsulage pour asian quasi_option
Diffstat (limited to 'rqmc.hpp')
-rw-r--r--rqmc.hpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/rqmc.hpp b/rqmc.hpp
index 62efbaa..415ab00 100644
--- a/rqmc.hpp
+++ b/rqmc.hpp
@@ -31,7 +31,29 @@ compose(Fct f, VA X) {
return compose_t<Fct, VA>(f, X);
};
-//
+template <typename VA>
+struct mean_t: public generator<double>
+{
+ mean_t(int n, VA X): n(n), X(X) {};
+ double operator()(){
+ double sum = 0;
+ for(int i=0; i<n; i++){
+ sum+=X();
+ }
+ return sum/n;
+ }
+ private :
+ int n; VA X;
+ };
+
+template <typename VA>
+inline mean_t<VA>
+mean(int n, VA X){
+ return mean_t<VA>(n, X);
+};
+
+
+//Les classes de monte-Carlo
template <typename L>
std::vector<double> monte_carlo(int n, L X)
@@ -55,6 +77,9 @@ std::vector<double> monte_carlo(int n, Fct f, L X)
return monte_carlo(n, compose(f, X));
};
+//Les classes de quasi-mean
+
+
struct quasi_gaussian : public var_alea<std::vector<double> >
{
quasi_gaussian (int d, double mean = 0, double std =1)
@@ -72,6 +97,8 @@ struct quasi_gaussian : public var_alea<std::vector<double> >
sobol sob;
};
+
+
struct gaussian_d : public var_alea<std::vector<double> >
{
gaussian_d(int d, double mean = 0, double std =1)