List of usage examples for java.lang Math sqrt
@HotSpotIntrinsicCandidate public static double sqrt(double a)
From source file:com.opengamma.analytics.financial.timeseries.analysis.RankTestIIDHypothesis.java
@Override public boolean testIID(final DoubleTimeSeries<?> x) { Validate.notNull(x, "x"); final double[] data = x.valuesArrayFast(); int t = 0;// w ww .j a va 2 s . com final int n = x.size(); double val; for (int i = 0; i < n - 1; i++) { val = data[i]; for (int j = i + 1; j < n; j++) { if (data[j] > val) { t++; } } } final double mean = n * (n - 1) / 4.; final double std = Math.sqrt(n * (n - 1) * (2 * n + 5.) / 72.); return Math.abs(t - mean) / std < _criticalValue; }
From source file:lsafunctions.LSA.java
private static RealMatrix normalizeMatrix(RealMatrix M) { double sumColumn = 0; // Matrix row = new Matrix(1, M.getColumnDimension()); RealMatrix row = MatrixUtils.createRealMatrix(1, M.getColumnDimension()); for (int j = 0; j < M.getColumnDimension(); j++) { sumColumn = 0;/*from w w w . j a v a 2 s . c o m*/ for (int k = 0; k < M.getRowDimension(); k++) { sumColumn += Math.pow(M.getEntry(k, j), 2); } sumColumn = Math.sqrt(sumColumn); row.setEntry(0, j, sumColumn); } for (int j = 0; j < M.getColumnDimension(); j++) { for (int k = 0; k < M.getRowDimension(); k++) { M.setEntry(k, j, M.getEntry(k, j) / row.getEntry(0, j)); } } return M; }
From source file:algorithms.quality.AttentionQuality.java
@Override public double getQuality(Colormap2D colormap) { // max L + max c (which is the same as a or b) double normFac = Math.sqrt(100 * 100 + 150 * 150); DescriptiveStatistics stats = new DescriptiveStatistics(); for (Point2D pt : sampling.getPoints()) { Color color = colormap.getColor(pt.getX(), pt.getY()); double[] lch = new CIELABLch().fromColor(color); double attention = Math.sqrt(lch[0] * lch[0] + lch[1] * lch[1]) / normFac; stats.addValue(attention);/*from w ww . jav a 2 s .co m*/ } return stats.getVariance(); }
From source file:IK.G.java
public static double sqrt(double in) { return Math.sqrt(in); }
From source file:info.debatty.jinu.SummaryStatistics.java
private static double calcMeanCI(final SummaryStatistics stats, final double level) { try {//from ww w . j a v a 2 s . c om // Create T Distribution with N-1 degrees of freedom TDistribution t_dist = new TDistribution(stats.getN() - 1); // Calculate critical value double crit_val = t_dist.inverseCumulativeProbability(1.0 - (1 - level) / 2); // Calculate confidence interval return crit_val * stats.getStandardDeviation() / Math.sqrt(stats.getN()); } catch (MathIllegalArgumentException e) { return Double.NaN; } }
From source file:geogebra.util.MyMath.java
final public static double asinh(double a) { return Math.log(a + Math.sqrt(a * a + 1.0)); }
From source file:net.gtaun.shoebill.data.Velocity.java
public float speed3d() { return (float) Math.sqrt(getX() * getX() + getY() * getY() + getZ() * getZ()); }
From source file:com.opengamma.analytics.financial.model.stochastic.BlackScholesGeometricBrownianMotionProcess.java
@Override public Function1D<Double, Double> getPathGeneratingFunction(final T t, final U u, final int steps) { Validate.notNull(t);//from w w w. jav a2s . c om Validate.notNull(u); if (steps < 1) { throw new IllegalArgumentException("Number of steps must be greater than zero"); } final double k = t.getStrike(); final double m = t.getTimeToExpiry(u.getDate()); final double sigma = u.getVolatility(m, k); final double b = u.getCostOfCarry(); final double dt = m / steps; final double sigmaSq = sigma * sigma; final double nu = dt * (b - 0.5 * sigmaSq); final double sigmaDt = sigma * Math.sqrt(dt); return new Function1D<Double, Double>() { @Override public Double evaluate(final Double e) { return nu + sigmaDt * e; } }; }
From source file:com.opengamma.analytics.financial.model.stochastic.BlackScholesArithmeticBrownianMotionProcess.java
@Override public Function1D<Double, Double> getPathGeneratingFunction(final T t, final U u, final int steps) { Validate.notNull(t);// w w w . jav a2 s .c o m Validate.notNull(u); if (steps < 1) { throw new IllegalArgumentException("Number of steps must be greater than zero"); } final double k = t.getStrike(); final double m = t.getTimeToExpiry(u.getDate()); final double sigma = u.getVolatility(m, k); final double b = u.getCostOfCarry(); final double dt = m / steps; final double sigmaSq = sigma * sigma; final double nu = dt * (b - 0.5 * sigmaSq); final double sigmaDt = sigma * Math.sqrt(dt); return new Function1D<Double, Double>() { @Override public Double evaluate(final Double e) { return Math.exp(nu + sigmaDt * e); } }; }
From source file:com.opengamma.analytics.financial.var.StudentTVaRParameters.java
public StudentTVaRParameters(final double horizon, final double periods, final double quantile, final double dof) { Validate.isTrue(horizon > 0, "horizon"); Validate.isTrue(periods > 0, "periods"); if (!ArgumentChecker.isInRangeInclusive(0, 1, quantile)) { throw new IllegalArgumentException("Quantile must be between 0 and 1"); }//from w w w.ja va 2 s .c om Validate.isTrue(dof > 0, "degrees of freedom"); _horizon = horizon; _periods = periods; _quantile = quantile; _dof = dof; _studentT = new StudentTDistribution(dof); _mult = Math.sqrt((_dof - 2) * horizon / dof / periods) * _studentT.getInverseCDF(quantile); _scale = horizon / periods; }