Examples of CumulativeNormalDistribution


Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution

    public double gaussianRegret(final double target) {
        final double m = statistics.mean();
        final double std = statistics.standardDeviation();
        final double variance = std * std;
        final CumulativeNormalDistribution gIntegral = new CumulativeNormalDistribution(m, std);
        final NormalDistribution g = new NormalDistribution(m, std);
        final double firstTerm = variance + m * m - 2.0 * target * m + target * target;
        final double alfa = gIntegral.op(target);
        final double secondTerm = m - target;
        final double beta = variance * g.op(target);
        final double result = alfa * firstTerm - beta * secondTerm;
        return result / alfa;
    }
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution

        // expectedShortfall must also be a positive quantity, so -MIN(*)
        return -Math.min(result, 0.0);
    }

    public double gaussianShortfall(final double target) {
        final CumulativeNormalDistribution gIntegral = new CumulativeNormalDistribution(statistics.mean(), statistics.standardDeviation());
        return gIntegral.op(target);
    }
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution

    }

    public double gaussianAverageShortfall(final double target) {
        final double m = statistics.mean();
        final double std = statistics.standardDeviation();
        final CumulativeNormalDistribution gIntegral = new CumulativeNormalDistribution(m, std);
        final NormalDistribution g = new NormalDistribution(m, std);
        return ((target - m) + std * std * g.op(target) / gIntegral.op(target));
    }
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution

                - dividendYield_.currentLink().forwardRate(t0, t0, Compounding.Continuous).rate() - 0.5 * vol * vol;

                df = 4 * thetav_ * kappav_ / (sigmav_ * sigmav_);
                ncp = 4 * kappav_ * Math.exp(-kappav_ * dt) / (sigmav_ * sigmav_ * (1 - Math.exp(-kappav_ * dt))) * x01;

                p = new CumulativeNormalDistribution().op(dw1);
                if (p < 0.0) {
                    p = 0.0;
                } else if (p >= 1.0) {
                    p = 1.0 - Constants.QL_EPSILON;
                }
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution

                mu = Math.log(dividendDiscount / discount) / variance - 0.5;
                lambda = Math.sqrt( mu * mu - 2.0 * Math.log(discount) / variance);
            }
            D1 = log_H_S / stdDev + lambda * stdDev;
            D2 = D1 - 2.0 * lambda * stdDev;
            final CumulativeNormalDistribution f = new CumulativeNormalDistribution();
            cum_d1 = f.op(D1);
            cum_d2 = f.op(D2);
            n_d1 = f.derivative(D1);
            n_d2 = f.derivative(D2);
        } else {
            // TODO: not tested yet
            mu = Math.log(dividendDiscount / discount) / variance - 0.5;
            lambda = Math.sqrt( mu * mu - 2.0 * Math.log(discount) / variance);
            if (log_H_S > 0) {
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution

        @Real final double d1 = Math.log(forward / strike) / stddev + 0.5 * stddev;
        @Real final double d2 = d1 - stddev;

        // TODO: code review
        final CumulativeNormalDistribution phi = new CumulativeNormalDistribution();
        @Real final double result = discount * optionType.toInteger()
        * (forward * phi.op(optionType.toInteger() * d1) - strike * phi.op(optionType.toInteger() * d2));

        if (result >= 0.0) return result;
        throw new ArithmeticException("a negative value was calculated"); // TODO: message
    }
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution

        if (strike==0.0) return (optionType==Option.Type.Call ? 1.0 : 0.0);
        final double d1 = Math.log((forward+displacement)/(strike+displacement))/stddev + 0.5*stddev;
        final double d2 = d1 - stddev;

        // TODO: code review
        final CumulativeNormalDistribution phi = new CumulativeNormalDistribution();
        return phi.op(optionType.toInteger() * d2);
    }
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution

        forward = forward + displacement;
        strike = strike + displacement;
        final double d1 = Math.log(forward/strike)/stddev + .5*stddev;

        // TODO: code review
        final CumulativeNormalDistribution cdf = new CumulativeNormalDistribution();
        return discount * forward * cdf.derivative(d1);
    }
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution

        final double d = (forward - strike) * optionType.ordinal(), h = d / stddev;
        if (stddev == 0.0) return discount * Math.max(d, 0.0);

        // TODO: code review
        final CumulativeNormalDistribution phi = new CumulativeNormalDistribution();
        @NonNegative
        final double result = discount * stddev * phi.derivative(h) + d * phi.op(h);
        if (result >= 0.0) return result;
        throw new ArithmeticException("negative value");
    }
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution

            this.signedForward_ = (optionType.toInteger() * (forward + displacement));
            this.undiscountedBlackPrice_ = (undiscountedBlackPrice);
            signedMoneyness_ = optionType.toInteger() * Math.log((forward + displacement) / (strike + displacement));

            // TODO: code review
            this.N_ = new CumulativeNormalDistribution();
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.