MC NPV averaging

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

MC NPV averaging

Lapin
Hi,

Can somebody tells me where the NPV is averaged in the MC simulation engine.
I can not locate it in the code and I am getting crazy...

Cheers
Reply | Threaded
Open this post in threaded view
|

Re: MC NPV averaging

Luigi Ballabio
On Mon, 2007-12-03 at 07:47 -0800, Yomi wrote:
> Can somebody tells me where the NPV is averaged in the MC simulation engine.
> I can not locate it in the code and I am getting crazy...

Sorry for the delay---I know I've a few mails of yours in the queue, but
I haven't had time to answer yet.

McSimulation::calculate() calls either McSimulation::value() or
McSimulation::valueWithSamples(). Both methods call
MonteCarloModel::addSamples(), which asks the path generator for paths,
passes them to the path pricer, and adds the result for each path to the
statistics accumulator. After this, the NPV is available as
mcModel_->sampleAccumulator().mean()---see for example
MCVanillaEngine::calculate() where this figure is fetched and stored in
the engine results.

Later,
        Luigi


--

Weiler's Law:
Nothing is impossible for the man who doesn't have to
do it himself.



-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: MC NPV averaging

Lapin
Thanks Luigi,

I got it now.
But it is still a bit messy in my mind on how to add new stats (like the likely coupon to be called).
This vector of statistics should be part of the engine, so except if I pass the vector in the PathPricer constructor, there is no way I can add any value to it in the path pricer.

Do you agree on that point?

Cheers

Luigi Ballabio wrote
On Mon, 2007-12-03 at 07:47 -0800, Yomi wrote:
> Can somebody tells me where the NPV is averaged in the MC simulation engine.
> I can not locate it in the code and I am getting crazy...

Sorry for the delay---I know I've a few mails of yours in the queue, but
I haven't had time to answer yet.

McSimulation::calculate() calls either McSimulation::value() or
McSimulation::valueWithSamples(). Both methods call
MonteCarloModel::addSamples(), which asks the path generator for paths,
passes them to the path pricer, and adds the result for each path to the
statistics accumulator. After this, the NPV is available as
mcModel_->sampleAccumulator().mean()---see for example
MCVanillaEngine::calculate() where this figure is fetched and stored in
the engine results.

Later,
        Luigi


--

Weiler's Law:
Nothing is impossible for the man who doesn't have to
do it himself.



-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users