protected internal override double survivalProbabilityImpl(double t)
        {
            GaussChebyshevIntegration integral = new GaussChebyshevIntegration(48);
            t_remapper remap_t = new t_remapper(this.defaultDensityImpl, t);
            // the Gauss-Chebyshev quadratures integrate over [-1,1],
            // hence the remapping (and the Jacobian term t/2)
            double P = 1.0 - integral.value(remap_t.value) * t / 2.0;

            //Utils.QL_ENSURE(P >= 0.0, "negative survival probability");
            return(Math.Max(P, 0.0));
        }
Beispiel #2
0
        // This method must be implemented in derived classes to
        // perform the actual calculations. When it is called,
        // range check has already been performed; therefore, it
        // must assume that extrapolation is required.
        #endregion

        //! hazard rate calculation

        #region DefaultProbabilityTermStructure implementation

        /*! survival probability calculation
         * implemented in terms of the hazard rate \f$ h(t) \f$ as
         * \f[
         * S(t) = \exp\left( - \int_0^t h(\tau) d\tau \right).
         * \f]
         *
         * \warning This default implementation uses numerical integration,
         *          which might be inefficient and inaccurate.
         *          Derived classes should override it if a more efficient
         *          implementation is available.
         */
        protected internal override double survivalProbabilityImpl(double t)
        {
            GaussChebyshevIntegration integral = new GaussChebyshevIntegration(48);

            // this stores the address of the method to integrate (so that
            // we don't have to insert its full expression inside the
            // integral below--it's long enough already)

            // the Gauss-Chebyshev quadratures integrate over [-1,1],
            // hence the remapping (and the Jacobian term t/2)
            return(Math.Exp(-integral.value(hazardRateImpl) * t / 2.0));
        }