Logo Search packages:      
Sourcecode: quantlib version File versions  Download package

Real QuantLib::PeizerPrattMethod2Inversion ( Real  z,
BigNatural  n 
) [inline]

Given an odd integer n and a real number z it returns p such that: 1 - CumulativeBinomialDistribution((n-1)/2, n, p) = CumulativeNormalDistribution(z)

Precondition:
n must be odd

Definition at line 135 of file binomialdistribution.hpp.

                                                                  {

        QL_REQUIRE(n%2==1,
                   "n must be an odd number: " << n << " not allowed");

        Real result = (z/(n+1.0/3.0+0.1/(n+1.0)));
        result *= result;
        result = std::exp(-result*(n+1.0/6.0));
        result = 0.5 + (z>0 ? 1 : -1) * std::sqrt((0.25 * (1.0-result)));
        return result;
    }


Generated by  Doxygen 1.6.0   Back to index