List of usage examples for java.lang Math pow
@HotSpotIntrinsicCandidate public static double pow(double a, double b)
From source file:org.wallerlab.yoink.density.service.densityProperties.SingleExponentialDecayDetectorComputer.java
/** * calculate SEDD of a denstiy point//from w w w . j a v a 2 s .c o m * * @param densityPoint * -{@link org.wallerlab.yoink.api.model.density.DensityPoint} * @param seddValue * pre-calculated * @return seddValue final-calculated */ protected double getSilvaValue(DensityPoint densityPoint, double seddValue) { double density = densityPoint.getDensity(); seddValue *= (4.0 / Math.pow(density, 8)); seddValue = Math.log((1.0 + seddValue)); return seddValue; }
From source file:com.opengamma.analytics.financial.model.volatility.surface.SABRATMVolatilityCalibrationFunction.java
public SABRDataBundle calibrate(final OptionDefinition option, final SABRDataBundle data) { Validate.notNull(option, "option"); Validate.notNull(data, "data"); final double beta = data.getBeta(); final double t = option.getTimeToExpiry(data.getDate()); final double rho = data.getRho(); final double ksi = data.getVolOfVol(); final double sigmaATM = data.getVolatility(t, option.getStrike()); final double b = data.getCostOfCarry(); final double f = data.getSpot() * Math.exp(b * t); final double beta1 = 1 - beta; final double f1 = Math.pow(f, beta1); final double a0 = -sigmaATM * f1; final double a1 = 1 + (2 - 3 * rho * rho) * ksi * ksi * t / 24; final double a2 = rho * beta * ksi * t / 4 / f1; final double a3 = beta1 * beta1 * t / 24 / f1 / f1; Double[] roots;//from w ww .j a va 2s.c o m if (CompareUtils.closeEquals(a3, 0, 1e-16)) { roots = QUADRATIC_FINDER.getRoots(new RealPolynomialFunction1D(new double[] { a0, a1, a2 })); } else { roots = ROOT_FINDER.getRoots(new RealPolynomialFunction1D(new double[] { a0, a1, a2, a3 })); } Arrays.sort(roots); if (roots[0] > 0) { return data.withAlpha(roots[0]); } for (final Double r : roots) { if (r > 0) { return data.withAlpha(r); } } throw new MathException("Could not find positive real root"); }
From source file:com.opengamma.analytics.math.interpolation.LogLinearInterpolator1D.java
@Override public Double interpolate(final Interpolator1DDataBundle model, final Double value) { Validate.notNull(value, "value"); Validate.notNull(model, "data bundle"); final InterpolationBoundedValues boundedValues = model.getBoundedValues(value); final Double x1 = boundedValues.getLowerBoundKey(); final Double y1 = boundedValues.getLowerBoundValue(); if (model.getLowerBoundIndex(value) == model.size() - 1) { return y1; }//from w ww. j a va 2 s . co m final Double x2 = boundedValues.getHigherBoundKey(); final Double y2 = boundedValues.getHigherBoundValue(); return Math.pow(y2 / y1, (value - x1) / (x2 - x1)) * y1; }
From source file:com.opengamma.analytics.math.statistics.descriptive.SampleNormalizedCentralMomentCalculator.java
/** * @param x The array of data, not null. Must contain at least two data points. * @return The normalized sample central moment. *//*w w w. ja v a2s . c o m*/ @Override public Double evaluate(final double[] x) { Validate.notNull(x); Validate.isTrue(x.length >= 2, "Need at least 2 data points to calculate normalized central moment"); if (_n == 0) { return 1.; } return _moment.evaluate(x) / Math.pow(STD_DEV.evaluate(x), _n); }
From source file:Main.java
public static int getPositionalNumber(int iSrc) { int positionnalNumber = 1; while (true) { if (iSrc / (int) Math.pow(10, positionnalNumber) == 0) break; positionnalNumber++;/*from w ww . j a v a2s . c om*/ } return positionnalNumber; }
From source file:Main.java
/** * Returns the luminance of a color.//from w w w .j ava2s . c o m * * Formula defined here: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef */ public static double calculateLuminance(int color) { double red = Color.red(color) / 255d; red = red < 0.03928 ? red / 12.92 : Math.pow((red + 0.055) / 1.055, 2.4); double green = Color.green(color) / 255d; green = green < 0.03928 ? green / 12.92 : Math.pow((green + 0.055) / 1.055, 2.4); double blue = Color.blue(color) / 255d; blue = blue < 0.03928 ? blue / 12.92 : Math.pow((blue + 0.055) / 1.055, 2.4); return (0.2126 * red) + (0.7152 * green) + (0.0722 * blue); }
From source file:com.github.dactiv.common.utils.EncodeUtils.java
private static long alphabetDecode(String str, int base) { Validate.notBlank(str);/*w w w . j av a 2s. c om*/ long result = 0; for (int i = 0; i < str.length(); i++) { result += ALPHABET.indexOf(str.charAt(i)) * Math.pow(base, i); } return result; }
From source file:com.galenframework.specs.RangeValue.java
public int asInt() { if (value > 0) { return (int) Math.floor(value / Math.pow(10, precision)); } else {/*from w w w .j a v a 2s . c o m*/ return (int) Math.ceil(value / Math.pow(10, precision)); } }
From source file:de.termininistic.serein.examples.benchmarks.functions.unimodal.ZakharovFunction.java
@Override public double map(RealVector v) { double[] x = v.toArray(); int n = x.length; double sum1 = 0.0; double sum2 = 0.0; for (int i = 0; i < n; i++) { sum1 += x[i] * x[i];//from w ww .ja v a 2s . c om sum2 += 0.5 * i * x[i]; } double result = sum1 + Math.pow(sum2, 2) + Math.pow(sum2, 4); return result; }
From source file:com.trickl.math.lanczos.TridiagonalMatrix.java
public TridiagonalMatrix() { this(Math.pow(epsilon, 2. / 3.)); }