List of usage examples for java.lang Math sqrt
@HotSpotIntrinsicCandidate public static double sqrt(double a)
From source file:Main.java
static public final float sqrt(float a) { return (float) Math.sqrt(a); }
From source file:com.vsthost.rnd.SandboxStrategyTest.java
/** * Defines a silly formula to be used in the objectives. * * @param x X// w w w .jav a2 s .c o m * @param y Y * @return Some silly result. */ public static double SillyFormula(double x, double y) { final double z = Math.sqrt(x * y == 0 ? 1 : Math.abs(x * y)); final double t = Math.pow(x <= 0 ? 1 : x, y); return x * x * x * +3 * x * x + 2 * x * y + 3 * y * y + y * y * y + 5 * x * y + z + t; }
From source file:drpc.KMeansDrpcQuery.java
private static double computeRootMeanSquare(double[] v) { double distance = 0; for (double aV : v) { distance += Math.pow((aV), 2); }/*from ww w . j ava 2 s . com*/ return Math.sqrt(distance / v.length); }
From source file:es.udc.gii.common.eaf.util.EAFMath.java
public static double perpendicularDistance(double[] pI, double[] pJ) { double pJmodule = (StatUtils.sumSq(pJ) != 0.0 ? Math.sqrt(StatUtils.sumSq(pJ)) : 0.0); return (pJmodule != 0.0 ? innerProduct(pI, pJ) / pJmodule : 0.0); }
From source file:Util.java
/** * Standard deviation is a statistical measure of spread or variability.The * standard deviation is the root mean square (RMS) deviation of the values * from their arithmetic mean./* ww w . java 2s .c o m*/ * * <b>populationStandardDeviation</b> normalizes values by N, where N is the sample size. This the * <i>Population Standard Deviation</i> * @param values * @return */ public static strictfp double populationStandardDeviation(double[] values) { double mean = mean(values); double n = values.length; double dv = 0; for (double d : values) { double dm = d - mean; dv += dm * dm; } return Math.sqrt(dv / n); }
From source file:Main.java
/** * Returns the distance between two given locations in meters. * * @param loc1 First location object/*from ww w .j a v a 2s . com*/ * @param loc2 Second location object * @return distance between Loc1 & Loc2 in meters. */ public static float getDistance(Location loc1, Location loc2) { double lat1 = loc1.getLatitude(); double lng1 = loc1.getLongitude(); double lat2 = loc2.getLatitude(); double lng2 = loc2.getLongitude(); double earthRad = 6371; //kilometers double dLatitude = Math.toRadians(lat2 - lat1); double dLongitude = Math.toRadians(lng2 - lng1); double a = Math.sin(dLatitude / 2) * Math.sin(dLatitude / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLongitude / 2) * Math.sin(dLongitude / 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); float dist = (float) (earthRad * c); dist = dist * MILES_TO_METER_CONVERSION; return dist; }
From source file:de.tynne.benchmarksuite.Main.java
private static double standardDeviationOf(DoubleStream doubleStream, double average) { double sum = doubleStream.map(x -> Math.pow(x - average, 2.)).average().getAsDouble(); return Math.sqrt(sum); }
From source file:Main.java
private static double transformLat(double x, double y) { double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)); ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0; ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0; return ret;/*from w w w . j a va 2 s . c o m*/ }
From source file:Main.java
public static double student_c(final double v) { return Math.exp(logGamma((v + 1.0) / 2.0)) / (Math.sqrt(3.141592653589793 * v) * Math.exp(logGamma(v / 2.0))); }
From source file:Main.java
private static void initialize(int size) { greatestFactor = new int[size]; // wheel factorization (sort of...) greatestFactor[1] = 1;//from w ww.ja v a 2 s . c om for (Integer seed : seeds) { for (int i = seed; i < size; i += seed) { greatestFactor[i] = seed; } } // now do modified Sieve of Er... int sqrt = (int) Math.floor(Math.sqrt(size) + 1); for (int prime = 2; prime < sqrt; prime++) { if (0 == greatestFactor[prime]) { for (int i = prime; i < size; i += prime) { greatestFactor[i] = prime; } } } // now flesh out the rest of the sieve. for (int i = sqrt; i < size; i++) { if (0 == greatestFactor[i]) { greatestFactor[i] = i; } } }