PathGenerator: Question relating to PathGenerator Test Case

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

PathGenerator: Question relating to PathGenerator Test Case

thusitha liyanage
Hi
Could some one please tell me the purpose of the ------for loop ------------ in the code below.

The code is in the test-suite of quantlib. The cpp file is pathgenerator.cpp.

------------------------------------------
        for (i=0; i<100; i++)
            generator.next();

        sample_type sample = generator.next();
        Real calculated = sample.value.back();
        Real error = std::fabs(calculated-expected);

--------------------------------------------
What I don't understand is why does it generate hundred samples, and then do the calculation of the variable ---Calculated---. Does it do some kind of averaging of all these paths?

Thanks a lot.

Thusi
Reply | Threaded
Open this post in threaded view
|

Re: PathGenerator: Question relating to PathGenerator Test Case

Luigi Ballabio
On Sat, 2009-01-03 at 01:24 -0800, thusi wrote:

> Could some one please tell me the purpose of the ------for loop ------------
> in the code below.
>
> The code is in the test-suite of quantlib. The cpp file is
> pathgenerator.cpp.
>
> ------------------------------------------
>         for (i=0; i<100; i++)
>             generator.next();
>
>         sample_type sample = generator.next();
>         Real calculated = sample.value.back();
>         Real error = std::fabs(calculated-expected);
>
> --------------------------------------------
> What I don't understand is why does it generate hundred samples, and then do
> the calculation of the variable ---Calculated---. Does it do some kind of
> averaging of all these paths?

No average---it just checks the value of the 101th sample against its
expected value. As a test, it's as good as any...

Luigi


--

Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.
-- Brian W. Kernighan



------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev