Login  Register

bugs in quantlib in bootstrap and CumulativeNormalDistribution

Posted by Xavier.Abulker on Sep 11, 2002; 11:27am
URL: http://quantlib.414.s1.nabble.com/bugs-in-quantlib-in-bootstrap-and-CumulativeNormalDistribution-tp2182.html

Hello Quantlib,
we found 2 bugs in Quanlib and I would like to know if the Quantlib user
group could do something:

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. "

Bug2: Europeanoption pricing on Unix:
On windows the example Europeanoption gives:
Method          Value   EstimatedError  Discrepancy     Rel. Discr.
Black Scholes   5.8308  0.0000          0.000000        0.000000
Call-Put parity 5.8308  N/A             4.44089e-15     0.000000

Now on unix the same EuropeanOption gives:

Method          Value   EstimatedError  Discrepancy     Rel. Discr.
Black Scholes   3.2422  0.0000          0.000000        0.000000
Call-Put parity 3.2422  N/A             0       0.000000

You see that the result is not the same.
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.

In VC++, "f_" is initialized through its' only construtor, and "sigma"
value is set to "1".
However, with gcc under UNIX, "f_" has not gone through any constructor,
and "sigma" value
is set to "0".  So, the difference caused the error output on UNIX.

For the moment we found we could fix it with
Math::CumulativeNormalDistribution EuropeanOption::f_
               = Math::CumulativeNormalDistribution(0,1);

in europeanoption.cpp but this is not a clean fix.

Could you please report that a bug and tell me if a fix is possible?

Thanks a lot

Xavier


*************************************************************************
Ce message et toutes les pieces jointes (ci-apres le "message") sont
confidentiels et etablis a l'intention exclusive de ses destinataires.
Toute utilisation ou diffusion non autorisee est interdite.
Tout message electronique est susceptible d'alteration.
La FIMAT et ses filiales declinent toute responsabilite au
titre de ce message s'il a ete altere, deforme ou falsifie.
                    ********
This message and any attachments (the "message") are confidential and
intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
E-mails are susceptible to alteration.
Neither FIMAT nor any of its subsidiaries or affiliates shall
be liable for the message if altered, changed or falsified.
*************************************************************************