List of usage examples for java.lang Math abs
@HotSpotIntrinsicCandidate public static double abs(double a)
From source file:com.opengamma.analytics.financial.timeseries.analysis.TurningPointIIDHypothesis.java
@Override public boolean testIID(final DoubleTimeSeries<?> x) { Validate.notNull(x, "x"); final double[] data = x.valuesArrayFast(); final int n = data.length; int t = 0;//from www .j a va 2 s . com double x0, x1, x2; for (int i = 1; i < n - 1; i++) { x0 = data[i - 1]; x1 = data[i]; x2 = data[i + 1]; if (x1 > x0 && x1 > x2) { t++; } else if (x1 < x0 && x1 < x2) { t++; } } final double mean = 2 * (n - 2.) / 3.; final double std = Math.sqrt((16 * n - 29.) / 90.); return Math.abs(t - mean) / std < _criticalValue; }
From source file:springfirst.MapController.java
@RequestMapping("/nearby") @ResponseBody/* ww w .j a v a 2s.c o m*/ public ArrayList<Location> nearby(@RequestParam(value = "x") float x, @RequestParam(value = "y") float y) { float y2 = Math.abs(y) - _longitudeAdjust; float x2 = x - _latitudeAdjust; float[] dimensions = new float[] { _latitudeSquare, _longitudeSquare }; float[] coords = new float[] { x2, y2 }; ArrayList<Location> data = MapService.search(coords, dimensions); while (data.size() < 10) { //TODO: adjust the coordinates dimensions[0] += _latitudeSquare; dimensions[1] += _longitudeSquare; coords[0] -= _latitudeAdjust; coords[1] -= _longitudeAdjust; data = MapService.search(coords, dimensions); } for (Location loc : data) { loc.setDistance(x, y); } data.sort(null); return data; }
From source file:com.opengamma.analytics.financial.timeseries.filter.SpikeDoubleTimeSeriesFilter.java
public void setMaxPercentageMove(final double maxPercentageMove) { if (maxPercentageMove < 0) { s_logger.info("Maximum percentage move must be positive; using absolute value"); }/*w w w . j a va 2s . co m*/ _maxPercentageMove = Math.abs(maxPercentageMove); }
From source file:net.adamjak.thomas.graph.application.commons.StatisticsUtils.java
public static DescriptiveStatistics statisticsWithoutExtremes(DescriptiveStatistics inputStatistics, GrubbsLevel grubbsLevel) throws IllegalArgumentException { if (inputStatistics == null || grubbsLevel == null) throw new IllegalArgumentException("Params inputStatistics and grubbsLevel can not be null."); int countInput = inputStatistics.getValues().length; Double avgInput = inputStatistics.getMean(); Double stdInput = inputStatistics.getStandardDeviation(); Double s = stdInput * Math.sqrt((countInput - 1.0) / countInput); Double criticalValue = grubbsLevel.getCriticalValue(countInput); DescriptiveStatistics outputStatistic = new DescriptiveStatistics(); for (double inpVal : inputStatistics.getValues()) { double test = Math.abs(inpVal - avgInput) / s; if (test <= criticalValue) { outputStatistic.addValue(inpVal); }//w w w. j a v a 2 s .com } return outputStatistic; }
From source file:com.example.PJS.java
public static double NORMSDIST(double z) { double sign = 1; if (z < 0) sign = -1;//from ww w . j av a2 s . c om return 0.5 * (1.0 + sign * erf(Math.abs(z) / Math.sqrt(2))); }
From source file:com.pureinfo.srm.common.ImageHelper.java
private static int getNumber(int _nX0, int _nX1) { int number = _nX0 + (Math.abs(random.nextInt()) % (_nX1 - _nX0)) * 3 / 5; return number > 170 ? 170 : number; }
From source file:com.sillelien.dollar.test.CircleCiParallelRule.java
@Override public Statement apply(Statement statement, @NotNull Description description) { boolean runTest = true; final String tName = description.getClassName() + "#" + description.getMethodName(); final String numNodes = System.getenv("CIRCLE_NODE_TOTAL"); final String curNode = System.getenv("CIRCLE_NODE_INDEX"); if (StringUtils.isBlank(numNodes) || StringUtils.isBlank(curNode)) { System.out.println("Running locally, so skipping"); } else {/*from w w w . ja va 2s .c om*/ final int hashCode = Math.abs(tName.hashCode()); int nodeToRunOn = hashCode % Integer.parseInt(numNodes); final int curNodeInt = Integer.parseInt(curNode); runTest = nodeToRunOn == curNodeInt; System.out.println( "currentNode: " + curNodeInt + ", targetNode: " + nodeToRunOn + ", runTest: " + runTest); if (!runTest) { return new Statement() { @Override public void evaluate() { Assume.assumeTrue("Skipping test, currentNode: " + curNode + ", targetNode: " + nodeToRunOn, false); } }; } } return statement; }
From source file:CoarseHashSet.java
/** * double the set size/*from w w w. j a v a2 s. c o m*/ */ @Override public void resize() { int oldCapacity = table.length; lock.lock(); try { if (oldCapacity != table.length) { return; // someone beat us to it } int newCapacity = 2 * oldCapacity; List<T>[] oldTable = table; table = (List<T>[]) new List[newCapacity]; for (int i = 0; i < newCapacity; i++) table[i] = new ArrayList<T>(); for (List<T> bucket : oldTable) { for (T x : bucket) { int myBucket = Math.abs(x.hashCode() % table.length); table[myBucket].add(x); } } } finally { lock.unlock(); } }
From source file:org.csml.tommo.sugar.heatmap.AbsoluteDiffOperation.java
@Override public double mix(double topValue, double bottomValue) { return Math.abs(super.mix(topValue, bottomValue)); }
From source file:com.caseystella.analytics.outlier.streaming.mad.ConfusionMatrix.java
private static boolean setContains(Set<Long> outliers, long prospectiveOutlier, long meanDiffBetweenTs, int timeBounds) { for (Long outlier : outliers) { if (Math.abs(outlier - prospectiveOutlier) <= timeBounds * meanDiffBetweenTs) { return true; }//www . j a v a2s. c om } return false; }