Examples of NonCentralChiSquaredDistribution


Examples of com.opengamma.analytics.math.statistics.distribution.NonCentralChiSquaredDistribution

        final double b = 1.0 / (1 - beta);
        final double x = b * b / sigma / sigma / t;
        final double a = Math.pow(k, 2 * (1 - beta)) * x;
        final double c = Math.pow(forward, 2 * (1 - beta)) * x;
        if (beta < 1) {
          final NonCentralChiSquaredDistribution chiSq1 = new NonCentralChiSquaredDistribution(b + 2, c);
          final NonCentralChiSquaredDistribution chiSq2 = new NonCentralChiSquaredDistribution(b, a);
          if (isCall) {
            return numeraire * (forward * (1 - chiSq1.getCDF(a)) - k * chiSq2.getCDF(c));
          }
          return numeraire * (k * (1 - chiSq2.getCDF(c)) - forward * chiSq1.getCDF(a));
        }
        final NonCentralChiSquaredDistribution chiSq1 = new NonCentralChiSquaredDistribution(-b, a);
        final NonCentralChiSquaredDistribution chiSq2 = new NonCentralChiSquaredDistribution(2 - b, c);
        if (isCall) {
          return numeraire * (forward * (1 - chiSq1.getCDF(c)) - k * chiSq2.getCDF(a));
        }
        return numeraire * (k * (1 - chiSq2.getCDF(a)) - forward * chiSq1.getCDF(c));
      }
    };
  }
View Full Code Here

Examples of org.jquantlib.math.distributions.NonCentralChiSquaredDistribution

        final double df = 4.0 * k() * theta() / sigma2;
        final double ncps = 2.0 * rho * rho * (r0 - phi_.get(0.0)) * Math.exp(h * t) / (rho + psi + b);
        final double ncpt = 2.0 * rho * rho * (r0 - phi_.get(0.0)) * Math.exp(h * t) / (rho + psi);

        final NonCentralChiSquaredDistribution chis = new NonCentralChiSquaredDistribution(df, ncps);
        final NonCentralChiSquaredDistribution chit = new NonCentralChiSquaredDistribution(df, ncpt);

        final double z = Math.log(super.A(t, s) / strike) / b;
        final double call = discountS * chis.op(2.0 * z * (rho + psi + b)) - strike * discountT
        * chit.op(2.0 * z * (rho + psi));
        if (type.equals(Option.Type.Call))
            return call;
        else
            return call - discountS + strike * discountT;

 
View Full Code Here

Examples of org.jquantlib.math.distributions.NonCentralChiSquaredDistribution

        final double /* @Real */df = 4.0 * k() * theta() / sigma2;
        final double /* @Real */ncps = 2.0 * rho * rho * x0() * Math.exp(h * t) / (rho + psi + b);
        final double /* @Real */ncpt = 2.0 * rho * rho * x0() * Math.exp(h * t) / (rho + psi);

        final NonCentralChiSquaredDistribution chis = new NonCentralChiSquaredDistribution(df, ncps);
        final NonCentralChiSquaredDistribution chit = new NonCentralChiSquaredDistribution(df, ncpt);

        final double /* @Real */z = Math.log(A(t, s) / strike) / b;
        final double /*@Real*/ call = discountS*chis.op(2.0*z*(rho+psi+b)) -
        strike*discountT*chit.op(2.0*z*(rho+psi));

        if (type == Option.Type.Call) {
            return 0.0;
        } else {
            return 1.0;
View Full Code Here

Examples of org.jquantlib.math.distributions.NonCentralChiSquaredDistribution

        final double df = 4.0 * k() * theta() / sigma2;
        final double ncps = 2.0 * rho * rho * (r0 - phi_.get(0.0)) * Math.exp(h * t) / (rho + psi + b);
        final double ncpt = 2.0 * rho * rho * (r0 - phi_.get(0.0)) * Math.exp(h * t) / (rho + psi);

        final NonCentralChiSquaredDistribution chis = new NonCentralChiSquaredDistribution(df, ncps);
        final NonCentralChiSquaredDistribution chit = new NonCentralChiSquaredDistribution(df, ncpt);

        final double z = Math.log(super.A(t, s) / strike) / b;
        final double call = discountS * chis.op(2.0 * z * (rho + psi + b)) - strike * discountT
        * chit.op(2.0 * z * (rho + psi));
        if (type.equals(Option.Type.Call))
            return call;
        else
            return call - discountS + strike * discountT;

 
View Full Code Here

Examples of org.jquantlib.math.distributions.NonCentralChiSquaredDistribution

        final double /* @Real */df = 4.0 * k() * theta() / sigma2;
        final double /* @Real */ncps = 2.0 * rho * rho * x0() * Math.exp(h * t) / (rho + psi + b);
        final double /* @Real */ncpt = 2.0 * rho * rho * x0() * Math.exp(h * t) / (rho + psi);

        final NonCentralChiSquaredDistribution chis = new NonCentralChiSquaredDistribution(df, ncps);
        final NonCentralChiSquaredDistribution chit = new NonCentralChiSquaredDistribution(df, ncpt);

        final double /* @Real */z = Math.log(A(t, s) / strike) / b;
        final double /*@Real*/ call = discountS*chis.op(2.0*z*(rho+psi+b)) -
        strike*discountT*chit.op(2.0*z*(rho+psi));

        if (type == Option.Type.Call) {
            return 0.0;
        } else {
            return 1.0;
View Full Code Here

Examples of org.jquantlib.math.distributions.NonCentralChiSquaredDistribution

    for (final double[] value : values) {
      final double df = value[0];
      final double ncp = value[1];
      final double x = value[2];
      final double expected = value[3];
      final NonCentralChiSquaredDistribution nccsd = new NonCentralChiSquaredDistribution(df, ncp);
      final double realised = nccsd.op(x);
      if (Math.abs(expected-realised)>1.0e-6)
        fail("Noncentral chi squared failed: df " + df
          + " ncp " + ncp
          + " x " + x
          + " expected " + expected
View Full Code Here

Examples of org.jquantlib.math.distributions.NonCentralChiSquaredDistribution

           }



public static double evaluateNonCentralChiSquaredDistribution(double df, double x, double ncp) {
     NonCentralChiSquaredDistribution ncd = new NonCentralChiSquaredDistribution(df,ncp);
     return ncd.op(x);

}
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.