List of usage examples for java.lang Math sqrt
@HotSpotIntrinsicCandidate public static double sqrt(double a)
From source file:geogebra.util.MyMath.java
final public static double acosh(double a) { return Math.log(a + Math.sqrt(a * a - 1.0)); }
From source file:com.opengamma.analytics.financial.var.NormalVaRParameters.java
public NormalVaRParameters(final double horizon, final double periods, final double quantile) { 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"); }/* ww w .j a v a 2 s. c om*/ _horizon = horizon; _periods = periods; _quantile = quantile; _z = NORMAL.getInverseCDF(quantile); _timeScaling = Math.sqrt(horizon / periods); }
From source file:net.gtaun.shoebill.data.Velocity.java
public float speed2d() { return (float) Math.sqrt(getX() * getX() + getY() * getY()); }
From source file:edu.oregonstate.eecs.mcplan.domains.voyager.Voyager.java
public static double distance(final Planet a, final Planet b) { return Math.sqrt(sq_distance(a, b)); }
From source file:Main.java
private static boolean unprotectedTest(long l) { for (int n = 2, max = (int) Math.ceil(Math.sqrt(l)); n <= max; n++) { if (l % n == 0) { return false; }//from w w w. java2 s . c o m } return true; }
From source file:com.opengamma.analytics.financial.model.volatility.surface.SkewnessKurtosisBlackScholesMertonEquivalentVolatilitySurfaceModel.java
@Override public VolatilitySurface getSurface(final OptionDefinition option, final SkewKurtosisOptionDataBundle data) { Validate.notNull(option, "option"); Validate.notNull(data, "data"); final double s = data.getSpot(); final double t = option.getTimeToExpiry(data.getDate()); final double k = option.getStrike(); final double sigma = data.getVolatility(t, k); final double b = data.getCostOfCarry(); final double skew = data.getAnnualizedSkew(); final double kurtosis = data.getAnnualizedFisherKurtosis(); final double d1 = (Math.log(s / k) + t * (b + sigma * sigma * 0.5)) / sigma / Math.sqrt(t); return new VolatilitySurface( ConstantDoublesSurface.from(sigma * (1 - skew * d1 / 6 - kurtosis * (1 - d1 * d1) / 24))); }
From source file:com.golemgame.util.SqrtFunction.java
public double value(double arg0) throws FunctionEvaluationException { if (arg0 <= 0) return 0; return Math.sqrt(arg0); }
From source file:com.itemanalysis.psychometrics.rasch.ScaleQualityStatistics.java
public double observedStandardDeviation() { return Math.sqrt(var.getResult()); }
From source file:com.anhth12.lambda.app.ml.als.Evaluation.java
/** * Computes root mean squared error/*ww w. j a v a 2 s .co m*/ * * @param mfModel * @param testData * @return */ static double rmse(MatrixFactorizationModel mfModel, JavaRDD<Rating> testData) { JavaPairRDD<Tuple2<Integer, Integer>, Double> testUserProductValues = testData .mapToPair(new RatingToTupleDouble()); RDD<Tuple2<Object, Object>> testUserProducts = (RDD<Tuple2<Object, Object>>) (RDD<?>) testUserProductValues .keys().rdd(); JavaRDD<Rating> predictions = testData.wrapRDD(mfModel.predict(testUserProducts)); double mse = predictions.mapToPair(new RatingToTupleDouble()).join(testUserProductValues).values() .mapToDouble(new DoubleFunction<Tuple2<Double, Double>>() { @Override public double call(Tuple2<Double, Double> valuePrediction) throws Exception { double diff = valuePrediction._1() - valuePrediction._2(); return diff * diff; } }).mean(); return Math.sqrt(mse); }
From source file:gui.Histograma.java
private static IntervalXYDataset criarDataset() { //guarda os dados do histograma HistogramDataset dados = new HistogramDataset(); int classes;// ww w . j a v a2s .c o m double valores[] = new double[amostra.size()]; //Definindo quantidade de classes if (amostra.size() <= 25) { classes = 5; } else { classes = (int) Math.round(Math.sqrt(amostra.size())); } //Criando vetor com valores da amostra for (int i = 0; i < amostra.size(); i++) { valores[i] = amostra.get(i); } //Adicionando os dataset para o histograma dados.addSeries("Frequncia das Amostras", valores, classes, min, max); return dados; }