Re: Doubt in Montecarlo generation of paths

Posted by Luigi Ballabio-2 on
URL: http://quantlib.414.s1.nabble.com/Doubt-in-Montecarlo-generation-of-paths-tp2898p2899.html

Ciao Luca,

On 2004.04.07 11:38, Berardi Luca wrote:

> I was looking at the code for setting up a generic Montecarlo
> simulation, in particular the PathGenerator class.
> There is something I could not really understand in the method next.  
> Looking at the section of code (where the brownian bridge is not
> used):
>
>             for (Size i=0; i<next_.value.size(); i++) {
>                 t = timeGrid_[i+1];
>                 dt = timeGrid_.dt(i);
>                 next_.value.drift()[i] = dt *
>                     diffProcess_->drift(t, asset_);
>                 next_.value.diffusion()[i] = sequence_.value[i] *
>                     QL_SQRT(diffProcess_->variance(t, asset_, dt));
>                 asset_ *= QL_EXP(next_.value.drift()[i] +
>                                  next_.value.diffusion()[i]);
>             }
>
> It not clear to me why asset_ is re-assigned as: asset_ *=
> QL_EXP(...).
> We are numerically integrating a diffusion process given by:
>
> d asset_ = drift(t, asset_)*dt + diffusion(t,asset_)*dW

No. We're integrating

d log(asset_) =  drift(t, asset_)*dt + diffusion(t,asset_)*dW

hence the exponential

> asset_ *=
>     QL_EXP(next_.value.drift()[i] + next_.value.diffusion()[i]);

(which by the way, can be written more concisely as

> asset_ *= QL_EXP(next_.value[i]);

if you're not concerned in separating the two components.)

Bye,
        Luigi