Package org.jquantlib.math.distributions

Examples of org.jquantlib.math.distributions.InverseCumulativeNormal


     * \exp (-u^2/2) du \f]
     */
    public double gaussianPercentile(final double percentile) {
        QL.require(percentile > 0.0 , "percentile must be > 0.0"); // QA:[RG]::verified // TODO: message
        QL.require(percentile < 1.0 , "percentile must be < 1.0"); // QA:[RG]::verified // TODO: message
        final InverseCumulativeNormal gInverse = new InverseCumulativeNormal(statistics.mean(), statistics.standardDeviation());
        return gInverse.op(percentile);
    }
View Full Code Here


    public double gaussianExpectedShortfall(final double percentile) {
        if (percentile >= 1.0 || percentile < 0.9)
            throw new IllegalArgumentException("percentile (" + percentile + ") out of range [0.9, 1)");
        final double m = statistics.mean();
        final double std = statistics.standardDeviation();
        final InverseCumulativeNormal gInverse = new InverseCumulativeNormal(m, std);
        final double var = gInverse.op(1.0 - percentile);
        final NormalDistribution g = new NormalDistribution(m, std);
        final 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(*)
 
View Full Code Here

        //FIXME: obtain original value :: this is a thread safety problem :(
        final boolean oldHighPrecision = settings.isRefineHighPrecisionUsingHalleysMethod();

        settings.setRefineHighPrecisionUsingHalleysMethod(false);
        InverseCumulativeNormal icn;

        //test the normal values
        icn = new InverseCumulativeNormal();
        for (final double[] normalTestvalue : normal_testvalues) {
            final double x_position = normalTestvalue[0];
            final double tolerance = 1.0e-15;//(Math.abs(x_position)<3.01) ? 1.0e-15: 1.0e-10;

            final double normal_expected = normalTestvalue[1];
            final double computed_normal = icn.op(x_position);
            if (Math.abs(normal_expected-computed_normal)>tolerance) {
                fail("x_position " + x_position + " normal_expected: " + normal_expected + " normal_computed: " + normal_expected);
            }
        }


        //test the normal values using high machine precision Halley's method
        settings.setRefineHighPrecisionUsingHalleysMethod(true);
        icn = new InverseCumulativeNormal();
        for (final double[] precisionTestvalue : precision_testvalues) {
            final double x_position = precisionTestvalue[0];
            final double tolerance = 1.0e-15;//(Math.abs(x_position)<3.01) ? 1.0e-15: 1.0e-10;

            final double precision_expected = precisionTestvalue[1];
            final double computed_precision = icn.op(x_position);

            if (Math.abs(precision_expected-computed_precision)>tolerance) {
                fail("x_position " + x_position + " precision_expected: " + precision_expected + " precision_computed: " + computed_precision);
            }
        }
View Full Code Here

          public static double evaluateGammaDistribution(double a, double x) {
              GammaDistribution gd = new GammaDistribution(a);
              return gd.op(x);
          }
           public static double evaluateInverseCumulativeNormal(double average, double sigma, double x){
               InverseCumulativeNormal icn = new InverseCumulativeNormal(average,sigma);
               return icn.op(x);
           }
View Full Code Here

   
    public /*@Real*/ double gaussianPercentile(/*@Real*/ double percentile) /* @ReadOnly */ {
    QL.require(percentile>0.0, "percentile must be > 0.0");
    QL.require(percentile<1.0, "percentile must be < 1.0");
    final InverseCumulativeNormal gInverse = new InverseCumulativeNormal(mean(), standardDeviation());
    return gInverse.op(percentile);
  }
View Full Code Here

     */
    public /*@Real*/ double gaussianExpectedShortfall(/*@Real*/ double percentile) /* @ReadOnly */ {
        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

TOP

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

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.