Package org.jquantlib.math.distributions

Examples of org.jquantlib.math.distributions.NormalDistribution


        testSingle(I, "f(x) = 1",      new Constant(1.0),               0.0, 1.0, 1.0);
        testSingle(I, "f(x) = x",      new Identity(),                  0.0, 1.0, 0.5);
        testSingle(I, "f(x) = x^2",    new Square(),                    0.0, 1.0, 1.0/3.0);
        testSingle(I, "f(x) = sin(x)", new Sin(),                       0.0, Constants.M_PI, 2.0);
        testSingle(I, "f(x) = cos(x)", new Cos(),                       0.0, Constants.M_PI, 0.0);
        testSingle(I, "f(x) = Gaussian(x)", new NormalDistribution(), -10.0, 10.0, 1.0);

//TODO: http://bugs.jquantlib.org/view.php?id=452
//        testSingle(I, "f(x) = Abcd2(x)",
//                AbcdSquared(0.07, 0.07, 0.5, 0.1, 8.0, 10.0),
//                5.0, 6.0,
View Full Code Here


        QL.info("Testing differential operators...");

        final double average = 0.0, sigma = 1.0;

        final NormalDistribution normal = new NormalDistribution(average,sigma);
        final CumulativeNormalDistribution cum = new CumulativeNormalDistribution(average,sigma);

        final double xMin = average - 4*sigma,
        xMax = average + 4*sigma;
        final int N = 10001;
        final double h = (xMax-xMin)/(N-1);

        final Array x = new Array(N), y = new Array(N), yi = new Array(N), yd = new Array(N);
        Array temp = new Array(N);
        final Array diff = new Array(N);

        int i;
        for(i=0; i < x.size(); i++) {
            x.set(i, xMin+h*i);
        }

        for(i = 0; i < x.size(); i++) {
            y.set(i, normal.op(x.get(i)));
        }

        for(i = 0; i < x.size(); i++) {
            yi.set(i, cum.op(x.get(i)));
        }

        for (i=0; i < x.size(); i++) {
            yd.set(i, normal.derivative(x.get(i)));
        }

        // define the differential operators
        final DZero D = new DZero(N,h);
        final DPlusMinus D2 = new DPlusMinus(N,h);
View Full Code Here

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

        QL.require(percentile<1.0 && percentile>=0.9, "percentile is out of range [0.9, 1)");
        /*@Real*/ double m = this.mean();
        /*@Real*/ double std = this.standardDeviation();
        final InverseCumulativeNormal gInverse = new InverseCumulativeNormal(m, std);
        /*@Real*/ double var = gInverse.op(1.0-percentile);
        final NormalDistribution g = new NormalDistribution(m, std);
        /*@Real*/ double result = m - std*std*g.op(var)/(1.0-percentile);
        // expectedShortfall must be a loss: this means that it has to be MIN(result, 0.0)
        // expectedShortfall must also be a positive quantity, so -MIN(*)
        return -Math.min(result, 0.0);
    }
View Full Code Here

     */
    public /*@Real*/ double gaussianAverageShortfall(/*@Real*/ double target) /* @ReadOnly */ {
      /*@Real*/ double m = mean();
      /*@Real*/ double std = 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

TOP

Related Classes of org.jquantlib.math.distributions.NormalDistribution

Copyright © 2018 www.massapicom. 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.