1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| struct brownian : public processus<double>
{
brownian(int n, double T=1)
: processus<double>(pow(2,n)+1), n(n), T(T), //ligne 33
h(T/pow(2., n)), G(0,h) {}; //ligne 34
result_type operator()();
result_type affine();
friend struct black_scholes;
protected:
int n;
double h, T;
gaussian G ; //ligne 41
};
result_type brownian::operator()() //ligne 43
{
value.clear();
state val_k(0,0);
value.push_back(val_k);
do
{val_k.first += h;
val_k.second += G();
value.push_back(val_k);
}
while (val_k.first < T);
return value;
} |
Partager