Login  Register

Re: Bug in MCAmericanBasketEngine class

Posted by Luigi Ballabio on Oct 09, 2005; 12:17pm
URL: http://quantlib.414.s1.nabble.com/Bug-in-MCAmericanBasketEngine-class-tp4110p4111.html

On Oct 9, 2005, at 6:12 PM, Joseph Wang wrote:

> Can you add the following lines and see if it fixes things....
>
>        std::vector<MultiPath> multipaths(N);
>        for (i=0; i<N/2; i++) {
>            multipaths[i] = multipathGenerator->next().value;
>            multipaths[N/2+i] = multipathGenerator->antithetic().value;
>        }
>        // Add an extra path if N is odd
>        if (N % 2 == 1) {
>            multipaths[N-1] = multipathGenerator->next().value;
>        }

Isn't it enough to make N even if it's not? At its declaration site,
you can write:

Size N = requiredSamples_ + (requiredSamples_ % 2);

Luigi