Package com.opengamma.analytics.math

Examples of com.opengamma.analytics.math.MathException


        funcC = func;
        funcB = func;
        funcA = func;
        break;
      default:
        throw new MathException("enum not found");
    }

    if (fdType != null) {
      switch (fdType) {
        case FORWARD:
          return (-1.5 * funcA.evaluate(dataA) + 2.0 * funcB.evaluate(dataB) - 0.5 * funcC.evaluate(dataC)) / delta;
        case BACKWARD:
          return (0.5 * funcA.evaluate(dataA) - 2.0 * funcB.evaluate(dataB) + 1.5 * funcC.evaluate(dataC)) / delta;
        case CENTRAL:
          return (funcC.evaluate(dataC) - funcA.evaluate(dataA)) / 2.0 / delta;
        default:
          throw new MathException("enum not found");
      }
    }
    throw new MathException("enum not found");
  }
View Full Code Here


    Validate.notNull(function, "function");
    final UnivariateRealFunction commonsFunction = CommonsMathWrapper.wrapUnivariate(function);
    try {
      return OPTIMIZER.optimize(commonsFunction, MINIMIZE, lowerBound, upperBound, startPosition);
    } catch (final FunctionEvaluationException e) {
      throw new MathException(e);
    } catch (final org.apache.commons.math.ConvergenceException e) {
      throw new MathException(e);
    }
  }
View Full Code Here

    Validate.notNull(function, "function");
    final UnivariateRealFunction commonsFunction = CommonsMathWrapper.wrapUnivariate(function);
    try {
      return OPTIMIZER.optimize(commonsFunction, MINIMIZE, -Double.MAX_VALUE, Double.MAX_VALUE, startPosition);
    } catch (final FunctionEvaluationException e) {
      throw new MathException(e);
    } catch (final org.apache.commons.math.ConvergenceException e) {
      throw new MathException(e);
    }
  }
View Full Code Here

    }
    final double afac = -_lnGamma.evaluate(_a) - _lnGamma.evaluate(_b) + _lnGamma.evaluate(_a + _b);
    double error;
    for (int j = 0; j < 10; j++) {
      if (CompareUtils.closeEquals(p, 0, 1e-16) || CompareUtils.closeEquals(p, 1, 1e-16)) {
        throw new MathException("a or b too small for accurate evaluation");
      }
      error = _beta.evaluate(p) - x;
      t = Math.exp(a1 * Math.log(p) + b1 * Math.log(1 - p) + afac);
      u = error / t;
      t = u / (1 - 0.5 * Math.min(1, u * (a1 / p - b1 / (1 - p))));
View Full Code Here

  public Double evaluate(final Double x) {
    Validate.isTrue(x >= 0 && x <= 1, "x must be in the range 0 to 1");
    try {
      return Beta.regularizedBeta(x, _a, _b, _eps, _maxIter);
    } catch (final org.apache.commons.math.MathException e) {
      throw new MathException(e);
    }
  }
View Full Code Here

    final MultivariateRealOptimizer optimizer = new NelderMead();
    final MultivariateRealFunction commonsFunction = CommonsMathWrapper.wrapMultivariate(function);
    try {
      return new DoubleMatrix1D(CommonsMathWrapper.unwrap(optimizer.optimize(commonsFunction, MINIMIZER, startPosition.getData())));
    } catch (final ConvergenceException e) {
      throw new MathException(e);
    } catch (final FunctionEvaluationException e) {
      throw new MathException(e);
    }
  }
View Full Code Here

  @Override
  public Double evaluate(final Double x) {
    try {
      return Gamma.regularizedGammaP(_a, x, _eps, _maxIter);
    } catch (final org.apache.commons.math.MathException e) {
      throw new MathException(e);
    }
  }
View Full Code Here

      @Override
      public Double evaluate(final Double x) {
        try {
          return lagrange.value(x);
        } catch (final org.apache.commons.math.MathException e) {
          throw new MathException(e);
        }
      }

    };
  }
View Full Code Here

        h = -_df2 * cdfd1 * (1 - 1 / _q1) - (1 + _df2 * NORMAL.getPDF(-d1) / _sigmaRootT) / _q1;
        error = Math.abs(_k - s - rhs) / _k;
        count++;
      }
      if (count == MAX_INT) {
        throw new MathException("max iterations exceeded");
      }
      s = (_k - rhs + h * s) / (1 + h);

      return s;
    }
View Full Code Here

    final double w1 = 0.5 - b / sigmaSq;
    final double w2 = 2 * r / sigmaSq;
    final double w3 = w1 * w1;
    final double w4 = w3 + w2;
    if (w4 < 0) {
      throw new MathException("beta will be complex (see Jira PLAT-2944)");
    }
    final double w5 = Math.sqrt(w4);
    final double beta = w1 + w5;

    final double w5Bar = 1.0;
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.MathException

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.