Package com.opengamma.analytics.math

Examples of com.opengamma.analytics.math.MathException


        w = c[j + 1] - d[j];
        diff = xArray[i + j] - value;
        t = (xArray[j] - value) * d[j] / diff;
        dd = t - c[j + 1];
        if (Math.abs(dd) < _eps) {
          throw new MathException("Interpolating function has a pole at x = " + value);
        }
        dd = w / dd;
        d[j] = c[j + 1] * dd;
        c[j] = t * dd;
      }
View Full Code Here


      } else if (delta > 0.95) {
        error += " It is possible that the smile exhibits arbitrable for very low strikes. Check that the put price is always increasing in strike. ";
      } else {
        error += " It is likely that the smile exhibits arbitrage";
      }
      throw new MathException(error + " " + e.getMessage());
    }

  }
View Full Code Here

        final double res = Math.sqrt(num / den);
        if (Doubles.isFinite(res)) {
          return res;
        }
        // return 0.0;
        throw new MathException("Local Volatility failure: " + res);
      }
    };
    return new LocalVolatilitySurfaceStrike(FunctionalDoublesSurface.from(surf));
  }
View Full Code Here

      final double expB = Math.exp(b * dx);
      final double df = a * (dx * expB / b - (expB - 1) / b / b);
      b = b - f / df;
      f = c + a / b * (Math.exp(b * dx) - 1);
      if (count > 50) {
        throw new MathException("fail to solve for b");
      }
      count++;
    }
    return b;
  }
View Full Code Here

        count++;
      } catch (final Exception e) {
      }
      tries++;
      if (tries > 20) {
        throw new MathException("Cannot fit data");
      }
    }
    if (gBest == null) {
      throw new IllegalStateException("Global estimate was null; should never happen");
    }
View Full Code Here

    final RungeKuttaIntegrator1D integrator = new RungeKuttaIntegrator1D(absoluteTolerance, relativeTolerance, NB_INTEGRATION);
    double pv = 0.0;
    try {
      pv = 1.0 / Math.sqrt(2.0 * Math.PI) * integrator.integrate(integrant, -limit, limit) * dfPayment * cms.getNotional() * cms.getPaymentYearFraction();
    } catch (final Exception e) {
      throw new MathException(e);
    }
    return MultipleCurrencyAmount.of(cms.getCurrency(), pv);
  }
View Full Code Here

          oldValue = xData[i];
          xData[i] += _eps;
          if (!domain.evaluate(x)) {
            xData[i] = oldValue - _twoEps;
            if (!domain.evaluate(x)) {
              throw new MathException("cannot get derivative at point " + x.toString() + " in direction " + i);
            }
            y[0] = function.evaluate(x);
            xData[i] = oldValue;
            y[2] = function.evaluate(x);
            xData[i] = oldValue - _eps;
View Full Code Here

          oldValue = xData[j];
          xData[j] += _eps;
          if (!domain.evaluate(x)) {
            xData[j] = oldValue - _twoEps;
            if (!domain.evaluate(x)) {
              throw new MathException("cannot get derivative at point " + x.toString() + " in direction " + j);
            }
            y[2] = mid;
            y[0] = function.evaluate(x);
            xData[j] = oldValue - _eps;
            y[1] = function.evaluate(x);
View Full Code Here

        final double[] y = new double[3];
        double[] w;

        if (!domain.evaluate(x + _eps)) {
          if (!domain.evaluate(x - _eps)) {
            throw new MathException("cannot get derivative at point " + x.toString());
          }
          y[0] = function.evaluate(x - _twoEps);
          y[1] = function.evaluate(x - _eps);
          y[2] = function.evaluate(x);
          w = wBack;
View Full Code Here

        directionSet[n - 1] = deltaX;
      }

      x0 = x;
    }
    throw new MathException("ConjugateDirection failed to converge after " + _maxIterations + " iterations, with a tolerance of " + _eps + ". Final position reached was " + x0.toString());
  }
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.