Package org.jquantlib.math.distributions

Examples of org.jquantlib.math.distributions.NormalDistribution.op()


        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


        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(*)
        return -Math.min(result, 0.0);
    }
View Full Code Here

    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));
    }

    /*
     * TODO: where do we need this one???????????????????????????????? //! Helper class for precomputed distributions class
     * StatsHolder { public: typedef Real value_type; StatsHolder(Real mean, Real standardDeviation) : mean_(mean),
View Full Code Here

        final NormalDistribution ND = new NormalDistribution();

        if (sigG > Constants.QL_EPSILON) {
            /*@Real*/ final double x_1  = (muG-Math.log(payoff.strike())+variance)/sigG;
            Nx_1 = CND.op(x_1);
            nx_1 = ND.op(x_1);
        } else {
            Nx_1 = (muG > Math.log(payoff.strike()) ? 1.0 : 0.0);
            nx_1 = 0.0;
        }
        greeks.vega = forwardPrice * riskFreeDiscount * ( (dmuG_dsig + sigG * dsigG_dsig)*Nx_1 + nx_1*dsigG_dsig );
View Full Code Here

            final double /* @Real */black_Sk = BlackFormula.blackFormula(payoff.optionType(), payoff.strike(), forwardSk, Math.sqrt(variance)) * riskFreeDiscount;
            final double /* @Real */hA = phi * (Sk - payoff.strike()) - black_Sk;

            final double /* @Real */d1_Sk = (Math.log(forwardSk / payoff.strike()) + 0.5 * variance) / Math.sqrt(variance);
            final double /* @Real */d2_Sk = d1_Sk - Math.sqrt(variance);
            final double /* @Real */part1 = forwardSk * normalDist.op(d1_Sk) / (alpha * Math.sqrt(variance));
            final double /* @Real */part2 = -phi * forwardSk * cumNormalDist.op(phi * d1_Sk) * Math.log(dividendDiscount) / Math.log(riskFreeDiscount);
            final double /* @Real */part3 = +phi * payoff.strike() * cumNormalDist.op(phi * d2_Sk);
            final double /* @Real */V_E_h = part1 + part2 + part3;

            final double /* @Real */b = (1 - h) * alpha * lambda_prime / (2 * (2 * lambda + beta - 1));
View Full Code Here

            final double /* @Real */chi_double_prime = 2 * b / (spot * spot) - temp_chi_prime / spot - c / (spot * spot);
            greeks.delta = phi * dividendDiscount * cumNormalDist.op(phi * d1_Sk)
            + (lambda / (spot * (1 - chi)) + chi_prime / ((1 - chi)*(1 - chi))) *
            (phi * (Sk - payoff.strike()) - black_Sk) * Math.pow((spot/Sk), lambda);

            greeks.gamma = phi * dividendDiscount * normalDist.op(phi*d1_Sk) /
            (spot * Math.sqrt(variance))
            + (2 * lambda * chi_prime / (spot * (1 - chi) * (1 - chi))
                    + 2 * chi_prime * chi_prime / ((1 - chi) * (1 - chi) * (1 - chi))
                    + chi_double_prime / ((1 - chi) * (1 - chi))
                    + lambda * (1 - lambda) / (spot * spot * (1 - chi)))
View Full Code Here

    final NormalDistribution normal = new NormalDistribution();

    for (final double[] testvalue : testvalues) {
      final double z = testvalue[0];
      final double expected = testvalue[1];
      final double computed = normal.op(z);
      final double tolerance = (Math.abs(z)<3.01) ? 1.0e-15: 1.0e-10;

      //assertEquals(expected, computed,tolerance);
      if(expected-computed>tolerance){
        fail("expected : " + expected + " but was "+ computed);
View Full Code Here

      if(expected-computed>tolerance){
        fail("expected : " + expected + " but was "+ computed);
      }

      //assertEquals(expected, normal.evaluate(-z),tolerance);
      if(Math.abs(expected-normal.op(-z))>tolerance){
        fail("expected: " + expected + " but was " + normal.op(-z));
      }
    }
  }
}
View Full Code Here

        fail("expected : " + expected + " but was "+ computed);
      }

      //assertEquals(expected, normal.evaluate(-z),tolerance);
      if(Math.abs(expected-normal.op(-z))>tolerance){
        fail("expected: " + expected + " but was " + normal.op(-z));
      }
    }
  }
}
View Full Code Here

            final double /* @Real */black_Sk = BlackFormula.blackFormula(payoff.optionType(), payoff.strike(), forwardSk, Math.sqrt(variance)) * riskFreeDiscount;
            final double /* @Real */hA = phi * (Sk - payoff.strike()) - black_Sk;

            final double /* @Real */d1_Sk = (Math.log(forwardSk / payoff.strike()) + 0.5 * variance) / Math.sqrt(variance);
            final double /* @Real */d2_Sk = d1_Sk - Math.sqrt(variance);
            final double /* @Real */part1 = forwardSk * normalDist.op(d1_Sk) / (alpha * Math.sqrt(variance));
            final double /* @Real */part2 = -phi * forwardSk * cumNormalDist.op(phi * d1_Sk) * Math.log(dividendDiscount) / Math.log(riskFreeDiscount);
            final double /* @Real */part3 = +phi * payoff.strike() * cumNormalDist.op(phi * d2_Sk);
            final double /* @Real */V_E_h = part1 + part2 + part3;

            final double /* @Real */b = (1 - h) * alpha * lambda_prime / (2 * (2 * lambda + beta - 1));
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.