List of usage examples for java.lang Double MIN_VALUE
double MIN_VALUE
To view the source code for java.lang Double MIN_VALUE.
Click Source Link
From source file:com.qasp.diego.arsp.indice_localFrag.java
public double w(Medicao m, double p) { double valor; try {//w w w .ja va 2 s.com valor = 1.0 / Math.pow(d(m), p); } catch (ArithmeticException e) { // Divisao por 0. (Rarissimo) valor = 1.0 / Math.pow(Double.MIN_VALUE, p); } return valor; }
From source file:edu.ku.brc.af.ui.forms.formatters.UIFieldFormatter.java
public Number getMinValue() { if (minValue == null && dataClass == BigDecimal.class) { minValue = Double.MIN_VALUE; }// w w w . j a v a 2s. com return minValue; }
From source file:io.lavagna.service.StatisticsServiceTest.java
@Test public void getAverageCardsPerUserOnProjectTest() { double averageUsers = statisticsService.getAverageCardsPerUserOnProject(board.getProjectId()); Assert.assertEquals(0, averageUsers, Double.MIN_VALUE); labelService.addLabelValueToCard(assigned.getId(), card.getId(), labelValueToUser, user, new Date()); averageUsers = statisticsService.getAverageCardsPerUserOnProject(board.getProjectId()); Assert.assertEquals(1, averageUsers, Double.MIN_VALUE); createArchivedCard();/* w w w . j a va2 s . c om*/ averageUsers = statisticsService.getAverageCardsPerUserOnProject(board.getProjectId()); Assert.assertEquals(1, averageUsers, Double.MIN_VALUE); }
From source file:org.renjin.primitives.random.ChiSquare.java
public static double qnchisq(double p, double df, double ncp, boolean lower_tail, boolean log_p) { final double accu = 1e-13; final double racc = 4 * SignRank.DBL_EPSILON; /* these two are for the "search" loops, can have less accuracy: */ final double Eps = 1e-11; /* must be > accu */ final double rEps = 1e-10; /* relative tolerance ... */ double ux, lx, ux0, nx, pp; if (DoubleVector.isNaN(p) || DoubleVector.isNaN(df) || DoubleVector.isNaN(ncp)) { return p + df + ncp; }//from w ww . ja va 2 s . c o m if (!DoubleVector.isFinite(df)) { return DoubleVector.NaN; } /* Was * df = floor(df + 0.5); * if (df < 1 || ncp < 0) ML_ERR_return_NAN; */ if (df < 0 || ncp < 0) { return DoubleVector.NaN; } //R_Q_P01_boundaries(p, 0, ML_POSINF); //#define R_Q_P01_boundaries(p, _LEFT_, _RIGHT_) //This macro is defined in /src/nmath/dpq.h if (log_p) { if (p > 0) { return DoubleVector.NaN; } if (p == 0) {/* upper bound*/ return lower_tail ? Double.POSITIVE_INFINITY : 0; } if (p == Double.NEGATIVE_INFINITY) { return lower_tail ? 0 : Double.POSITIVE_INFINITY; } } else { /* !log_p */ if (p < 0 || p > 1) { return DoubleVector.NaN; } if (p == 0) { return lower_tail ? 0 : Double.POSITIVE_INFINITY; } if (p == 1) { return lower_tail ? Double.POSITIVE_INFINITY : 0; } } /* Invert pnchisq(.) : * 1. finding an upper and lower bound */ { /* This is Pearson's (1959) approximation, which is usually good to 4 figs or so. */ double b, c, ff; b = (ncp * ncp) / (df + 3 * ncp); c = (df + 3 * ncp) / (df + 2 * ncp); ff = (df + 2 * ncp) / (c * c); ux = b + c * Distributions.qchisq(p, ff, lower_tail, log_p); if (ux < 0) { ux = 1; } ux0 = ux; } p = Normal.R_D_qIv(p, log_p ? 1.0 : 0.0); if (!lower_tail && ncp >= 80) { /* pnchisq is only for lower.tail = TRUE */ if (p < 1e-10) { //ML_ERROR(ME_PRECISION, "qnchisq"); //How to write this error message? } p = 1. - p; lower_tail = true; } if (lower_tail) { if (p > 1 - SignRank.DBL_EPSILON) { return Double.POSITIVE_INFINITY; } pp = Math.min(1 - SignRank.DBL_EPSILON, p * (1 + Eps)); //This is equ to while loop! for (ux = ux; ux < Double.MAX_VALUE && pnchisq_raw(ux, df, ncp, Eps, rEps, 10000, true) < pp; ux *= 2) { } pp = p * (1 - Eps); for (lx = Math.min(ux0, Double.MAX_VALUE); lx > Double.MIN_VALUE && pnchisq_raw(lx, df, ncp, Eps, rEps, 10000, true) > pp; lx *= 0.5) { } } else { if (p > 1 - SignRank.DBL_EPSILON) { return 0.0; } pp = Math.min(1 - SignRank.DBL_EPSILON, p * (1 + Eps)); for (ux = ux; ux < Double.MAX_VALUE && pnchisq_raw(ux, df, ncp, Eps, rEps, 10000, false) > pp; ux *= 2) { } pp = p * (1 - Eps); for (lx = Math.min(ux0, Double.MAX_VALUE); lx > Double.MIN_VALUE && pnchisq_raw(lx, df, ncp, Eps, rEps, 10000, false) < pp; lx *= 0.5) { } } /* 2. interval (lx,ux) halving : */ if (lower_tail) { do { nx = 0.5 * (lx + ux); if (pnchisq_raw(nx, df, ncp, accu, racc, 100000, true) > p) { ux = nx; } else { lx = nx; } } while ((ux - lx) / nx > accu); } else { do { nx = 0.5 * (lx + ux); if (pnchisq_raw(nx, df, ncp, accu, racc, 100000, false) < p) { ux = nx; } else { lx = nx; } } while ((ux - lx) / nx > accu); } return 0.5 * (ux + lx); }
From source file:org.apache.flink.table.codegen.SortCodeGeneratorTest.java
private Object value1(InternalType type, Random rnd) { if (type.equals(InternalTypes.BOOLEAN)) { return false; } else if (type.equals(InternalTypes.BYTE)) { return Byte.MIN_VALUE; } else if (type.equals(InternalTypes.SHORT)) { return Short.MIN_VALUE; } else if (type.equals(InternalTypes.INT)) { return Integer.MIN_VALUE; } else if (type.equals(InternalTypes.LONG)) { return Long.MIN_VALUE; } else if (type.equals(InternalTypes.FLOAT)) { return Float.MIN_VALUE; } else if (type.equals(InternalTypes.DOUBLE)) { return Double.MIN_VALUE; } else if (type.equals(InternalTypes.STRING)) { return BinaryString.fromString(""); } else if (type instanceof DecimalType) { DecimalType decimalType = (DecimalType) type; return Decimal.fromBigDecimal(new BigDecimal(Integer.MIN_VALUE), decimalType.precision(), decimalType.scale());/*ww w . j a v a2 s . com*/ } else if (type instanceof ArrayType) { byte[] bytes = new byte[rnd.nextInt(7) + 1]; rnd.nextBytes(bytes); BinaryArray array = BinaryArray.fromPrimitiveArray(bytes); for (int i = 0; i < bytes.length; i++) { array.setNullByte(i); } return array; } else if (type.equals(InternalTypes.BINARY)) { byte[] bytes = new byte[rnd.nextInt(7) + 1]; rnd.nextBytes(bytes); return bytes; } else if (type instanceof RowType) { return GenericRow.of(new Object[] { null }); } else if (type instanceof GenericType) { return new BinaryGeneric<>(rnd.nextInt(), IntSerializer.INSTANCE); } else { throw new RuntimeException("Not support!"); } }
From source file:org.lpe.common.util.LpeNumericUtils.java
/** * Remove outliers in keys by calculating the distance to the neighbor * points. If the distance of a point to its neighbors is quite high, the * point is considered as an outlier./*from w ww. jav a2 s . co m*/ * * @param list * list of pairs * @param noiseThreshold * noise threshold * @param windowSize * window size to include neigbors for consideration * @param <T> * value type * @return filtered list of pairs */ public static <T extends Number> NumericPairList<Double, T> removeNoiseInKeys(NumericPairList<Double, T> list, double noiseThreshold, int windowSize) { NumericPairList<Double, T> result = new NumericPairList<>(); double[] noiseMetrics = new double[list.size()]; double maxNoise = Double.MIN_VALUE; for (int i = 0; i < list.size(); i++) { double sum = 0; double count = 0; for (int j = i - windowSize / 2; j <= i + windowSize / 2; j++) { if (j < 0 || j >= list.size() || i == j) { continue; } sum += Math.abs(list.get(i).getKey() - list.get(j).getKey()); count += 1.0; } noiseMetrics[i] = sum / count; if (noiseMetrics[i] > maxNoise) { maxNoise = noiseMetrics[i]; } } for (int i = 0; i < noiseMetrics.length; i++) { double relativeNoise = noiseMetrics[i] / maxNoise; if (relativeNoise < noiseThreshold) { result.add(new NumericPair<Double, T>(list.get(i).getKey(), list.get(i).getValue())); } } return result; }
From source file:com.eventsourcing.postgresql.PostgreSQLJournalTest.java
@Test @SneakyThrows//from www. ja v a 2 s . c o m public void serializationValue() { assertEquals(serializationResult(TestClass.builder().pByte(Byte.MIN_VALUE).build()).pByte(), Byte.MIN_VALUE); assertEquals(serializationResult(TestClass.builder().pByte(Byte.MAX_VALUE).build()).pByte(), Byte.MAX_VALUE); assertEquals((byte) serializationResult(TestClass.builder().oByte(Byte.MIN_VALUE).build()).oByte(), Byte.MIN_VALUE); assertEquals((byte) serializationResult(TestClass.builder().oByte(Byte.MAX_VALUE).build()).oByte(), Byte.MAX_VALUE); assertEquals( serializationResult(TestClass.builder().pByteArr("Hello, world".getBytes()).build()).pByteArr(), "Hello, world".getBytes()); assertEquals( serializationResult(TestClass.builder().oByteArr(toObject(("Hello, world").getBytes())).build()) .oByteArr(), "Hello, world".getBytes()); assertEquals(serializationResult(TestClass.builder().pShort(Short.MIN_VALUE).build()).pShort(), Short.MIN_VALUE); assertEquals((short) serializationResult(TestClass.builder().oShort(Short.MAX_VALUE).build()).oShort(), Short.MAX_VALUE); assertEquals(serializationResult(TestClass.builder().pInt(Integer.MIN_VALUE).build()).pInt(), Integer.MIN_VALUE); assertEquals((int) serializationResult(TestClass.builder().oInt(Integer.MAX_VALUE).build()).oInt(), Integer.MAX_VALUE); assertEquals(serializationResult(TestClass.builder().pLong(Long.MIN_VALUE).build()).pLong(), Long.MIN_VALUE); assertEquals((long) serializationResult(TestClass.builder().oLong(Long.MAX_VALUE).build()).oLong(), Long.MAX_VALUE); assertEquals(serializationResult(TestClass.builder().pFloat(Float.MIN_VALUE).build()).pFloat(), Float.MIN_VALUE); assertEquals(serializationResult(TestClass.builder().oFloat(Float.MAX_VALUE).build()).oFloat(), Float.MAX_VALUE); assertEquals(serializationResult(TestClass.builder().pDouble(Double.MIN_VALUE).build()).pDouble(), Double.MIN_VALUE); assertEquals(serializationResult(TestClass.builder().oDouble(Double.MAX_VALUE).build()).oDouble(), Double.MAX_VALUE); assertEquals(serializationResult(TestClass.builder().pBoolean(true).build()).pBoolean(), true); assertEquals(serializationResult(TestClass.builder().pBoolean(false).build()).pBoolean(), false); assertEquals((boolean) serializationResult(TestClass.builder().oBoolean(true).build()).oBoolean(), true); assertEquals((boolean) serializationResult(TestClass.builder().oBoolean(false).build()).oBoolean(), false); assertEquals(serializationResult(TestClass.builder().str("Hello, world").build()).str(), "Hello, world"); UUID uuid = UUID.randomUUID(); assertEquals(serializationResult(TestClass.builder().uuid(uuid).build()).uuid(), uuid); assertEquals(serializationResult(TestClass.builder().e(TestClass.E.B).build()).e(), TestClass.E.B); assertEquals(serializationResult(TestClass.builder().value(new SomeValue("test")).build()).value().value(), "test"); assertEquals(serializationResult(TestClass.builder() .value1(new SomeValue1(Collections.singletonList(new SomeValue2(new SomeValue("test"))))).build()) .value1().value().get(0).value().value(), "test"); ArrayList<List<String>> l = new ArrayList<>(); ArrayList<String> l1 = new ArrayList<>(); l1.add("test"); l.add(l1); assertEquals(serializationResult(TestClass.builder().list(l).build()).list().get(0).get(0), "test"); Map<String, List<String>> map = new HashMap<>(); LinkedList<String> list = new LinkedList<>(Arrays.asList("Hello")); map.put("test", list); map.put("anothertest", list); assertEquals(serializationResult(TestClass.builder().map(map).build()).map().get("test").get(0), "Hello"); assertEquals(serializationResult(TestClass.builder().map(map).build()).map().get("anothertest").get(0), "Hello"); assertFalse( serializationResult(TestClass.builder().optional(Optional.empty()).build()).optional().isPresent()); assertTrue(serializationResult(TestClass.builder().optional(Optional.of("test")).build()).optional() .isPresent()); assertEquals( serializationResult(TestClass.builder().optional(Optional.of("test")).build()).optional().get(), "test"); BigDecimal bigDecimal = new BigDecimal("0.00000000000000000000000000001"); assertEquals(serializationResult(TestClass.builder().bigDecimal(bigDecimal).build()).bigDecimal(), bigDecimal); BigInteger bigInteger = new BigInteger("100001"); assertEquals(serializationResult(TestClass.builder().bigInteger(bigInteger).build()).bigInteger(), bigInteger); Date date = new Date(); assertEquals(serializationResult(TestClass.builder().date(date).build()).date(), date); }
From source file:org.deegree.ogcwebservices.wms.dataaccess.ID2PInterpolation.java
private int buildQuadtree(FeatureCollection fc) throws IndexException { Iterator<Feature> iterator = fc.iterator(); double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; String tmp = prop.getProperty("z_value"); int count = 0; while (iterator.hasNext()) { Feature feat = iterator.next();/*from w w w . j av a2 s .co m*/ Point point = (Point) feat.getDefaultGeometryPropertyValue(); QualifiedName qn = new QualifiedName(tmp); Object o = feat.getDefaultProperty(qn).getValue(); if (o != null) { Double zValue = Double.parseDouble(o.toString()); point = GeometryFactory.createPoint(point.getX(), point.getY(), null); quadtree.insert(new DataTuple(point.getX(), point.getY(), zValue.doubleValue()), point); if (zValue < min) { min = zValue; } if (zValue > max) { max = zValue; } count++; } } System.out.println("min value : " + min); System.out.println("max value : " + max); return count; }
From source file:org.amanzi.neo.models.impl.network.NetworkModelTest.java
@Test public void testCheckCreateElementIfSiteDefinedSuccess() throws ModelException { parentElement = new DataElement(getNodeMock()); Map<String, Object> properties = getProperties(); properties.put(GEO_NODE_PROPERTIES.getLatitudeProperty(), Double.MIN_VALUE); properties.put(GEO_NODE_PROPERTIES.getLongitudeProperty(), Double.MAX_VALUE); properties.put(GENERAL_NODE_PROPERTIES.getNodeNameProperty(), DEFAULT_ELEMENT_NAME); DataElement mockedSite = new DataElement(getNodeMock(properties)); doReturn(mockedSite).when(networkModel).createDefaultElement(NetworkElementType.SITE, parentElement, DEFAULT_ELEMENT_NAME, properties); networkModel.createElement(NetworkElementType.SITE, parentElement, DEFAULT_ELEMENT_NAME, properties); verify(networkModel).createSite(parentElement, DEFAULT_ELEMENT_NAME, (Double) properties.get(GEO_NODE_PROPERTIES.getLatitudeProperty()), (Double) properties.get(GEO_NODE_PROPERTIES.getLongitudeProperty()), properties); }
From source file:DataPreProcess.ConvertedTrace.java
private void normalize_matrix_row() {//Normalize each type of activities to scale 0~1 for (int row = 0; row < Matrix.length; row++) { double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; for (int col = 0; col < Matrix[row].length; col++) { min = Matrix[row][col] < min ? Matrix[row][col] : min; max = Matrix[row][col] > max ? Matrix[row][col] : max; }/*from www . j a v a 2 s .com*/ for (int col = 0; col < Matrix[row].length; col++) { if ((max - min) == 0) { Matrix[row][col] = 0; } else { double val = (Matrix[row][col] - min) / (max - min); Matrix[row][col] = Double.parseDouble(round.format(val)); } } } }