Login  Register

Re: bugs in quantlib in bootstrap and CumulativeNormalDistribution

Posted by Luigi Ballabio-2 on Sep 18, 2002; 7:31am
URL: http://quantlib.414.s1.nabble.com/bugs-in-quantlib-in-bootstrap-and-CumulativeNormalDistribution-tp2182p2184.html

Hi Xavier,
         sorry for the delay, but we're having some hectic weeks and
QuantLib has to get behind...

At 07:21 PM 9/11/02 +0200, [hidden email] wrote:

>Bug 1: already reported  :
>
>"Crashing error in bootstrap:
>Building piecewiseFlatForward curve with futures and swaps only, the
>function crash.
>As far as I understand,  This is because in FuturesRateHelper'
>discountGuess() function it calls discountImpl which try to get a value
>with array index -1.
>As a safety guard, I think in bootstrap() of PiecewiseFlatForward, we
>should have
>  double guess= ( (i==1)? Null< double >() : instrument->discountGuess() );
>instead of
>double guess = instrument->discountGuess();
>To prevent this from happening. "

I haven't been able to reproduce this (and besides, I've had a look at
discountImpl and it seems sound---i.e., steps are taken to ensure that
the array is not accessed out of bounds).
Can you send me a set of data for which the bootstrapping fails?


>Bug2: Europeanoption pricing on Unix:
>We check the code and found that in "europeanoption.hpp" the following
>const static member is declared:
>
>    static const Math::CumulativeNormalDistribution f_;
>
>This variable "f_" is never explicitly initialized, thus it is up to the
>compilor to decide what to do when it is first used.

Argh. I'm tempted to blame the compiler for this, as the above is
initialized in europeanoption.cpp as
     const Math::CumulativeNormalDistribution EuropeanOption::f_;
which should be equivalent to
     const Math::CumulativeNormalDistribution EuropeanOption::f_ =
         Math::CumulativeNormalDistribution();
which in turn should properly initialize f_ with a sigma=1.
However, I'm too lazy to look up the C++ standard, so I might be wrong.

Anyway, let's try to code around this. What happens on Unix if you:
a) remove the line
         static const Math::CumulativeNormalDistribution f_;
    from europeanoption.hpp
b) replace the line
         const Math::CumulativeNormalDistribution EuropeanOption::f_;
    in europeanoption.cpp with
         namespace {
             const Math::CumulativeNormalDistribution f_;
         }
and leave the rest unmodified?

Later,
         Luigi