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.stratio.ingestion.sink.cassandra.EventParserTest.java
@Test public void shouldParsePrimitiveTypes() throws Exception { Object integer = EventParser.parseValue("1", DataType.Name.INT); assertThat(integer).isInstanceOf(Integer.class).isEqualTo(1); integer = EventParser.parseValue(Integer.toString(Integer.MAX_VALUE), DataType.Name.INT); assertThat(integer).isInstanceOf(Integer.class).isEqualTo(Integer.MAX_VALUE); integer = EventParser.parseValue(Integer.toString(Integer.MIN_VALUE), DataType.Name.INT); assertThat(integer).isInstanceOf(Integer.class).isEqualTo(Integer.MIN_VALUE); integer = EventParser.parseValue(" 1 2 ", DataType.Name.INT); assertThat(integer).isInstanceOf(Integer.class).isEqualTo(12); Object counter = EventParser.parseValue("1", DataType.Name.COUNTER); assertThat(counter).isEqualTo(1L);//w w w . j a v a2 s.c o m counter = EventParser.parseValue(Long.toString(Long.MAX_VALUE), DataType.Name.COUNTER); assertThat(counter).isEqualTo(Long.MAX_VALUE); counter = EventParser.parseValue(Long.toString(Long.MIN_VALUE), DataType.Name.COUNTER); assertThat(counter).isEqualTo(Long.MIN_VALUE); counter = EventParser.parseValue(" 1 2 ", DataType.Name.COUNTER); assertThat(counter).isEqualTo(12L); Object _float = EventParser.parseValue("1", DataType.Name.FLOAT); assertThat(_float).isInstanceOf(Float.class).isEqualTo(1f); _float = EventParser.parseValue("1.0", DataType.Name.FLOAT); assertThat(_float).isInstanceOf(Float.class).isEqualTo(1f); _float = EventParser.parseValue(Float.toString(Float.MAX_VALUE), DataType.Name.FLOAT); assertThat(_float).isInstanceOf(Float.class).isEqualTo(Float.MAX_VALUE); _float = EventParser.parseValue(Float.toString(Float.MIN_VALUE), DataType.Name.FLOAT); assertThat(_float).isInstanceOf(Float.class).isEqualTo(Float.MIN_VALUE); _float = EventParser.parseValue(" 1 . 0 ", DataType.Name.FLOAT); assertThat(_float).isInstanceOf(Float.class).isEqualTo(1f); Object _double = EventParser.parseValue("1", DataType.Name.DOUBLE); assertThat(_double).isInstanceOf(Double.class).isEqualTo(1.0); _double = EventParser.parseValue("0", DataType.Name.DOUBLE); assertThat(_double).isInstanceOf(Double.class).isEqualTo(0.0); _double = EventParser.parseValue(Double.toString(Double.MAX_VALUE), DataType.Name.DOUBLE); assertThat(_double).isInstanceOf(Double.class).isEqualTo(Double.MAX_VALUE); _double = EventParser.parseValue(Double.toString(Double.MIN_VALUE), DataType.Name.DOUBLE); assertThat(_double).isInstanceOf(Double.class).isEqualTo(Double.MIN_VALUE); _double = EventParser.parseValue(" 1 . 0 ", DataType.Name.DOUBLE); assertThat(_double).isInstanceOf(Double.class).isEqualTo(1.0); for (DataType.Name type : Arrays.asList(DataType.Name.BIGINT)) { Object bigInteger = EventParser.parseValue("1", type); assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(1L); bigInteger = EventParser.parseValue("0", type); assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(0L); bigInteger = EventParser.parseValue(Long.toString(Long.MAX_VALUE), type); assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(Long.MAX_VALUE); bigInteger = EventParser.parseValue(Long.toString(Long.MIN_VALUE), type); assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(Long.MIN_VALUE); } for (DataType.Name type : Arrays.asList(DataType.Name.VARINT)) { Object bigInteger = EventParser.parseValue("1", type); assertThat(bigInteger).isInstanceOf(BigInteger.class).isEqualTo(BigInteger.ONE); bigInteger = EventParser.parseValue("0", type); assertThat(bigInteger).isInstanceOf(BigInteger.class).isEqualTo(BigInteger.ZERO); bigInteger = EventParser.parseValue( BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.valueOf(2L)).toString(), type); assertThat(bigInteger).isInstanceOf(BigInteger.class) .isEqualTo(BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.valueOf(2L))); bigInteger = EventParser.parseValue( BigInteger.valueOf(Long.MIN_VALUE).multiply(BigInteger.valueOf(2L)).toString(), type); assertThat(bigInteger).isInstanceOf(BigInteger.class) .isEqualTo(BigInteger.valueOf(Long.MIN_VALUE).multiply(BigInteger.valueOf(2L))); } Object bigDecimal = EventParser.parseValue("1", DataType.Name.DECIMAL); assertThat(bigDecimal).isInstanceOf(BigDecimal.class).isEqualTo(BigDecimal.valueOf(1)); bigDecimal = EventParser.parseValue("0", DataType.Name.DECIMAL); assertThat(bigDecimal).isInstanceOf(BigDecimal.class).isEqualTo(BigDecimal.valueOf(0)); bigDecimal = EventParser.parseValue( BigDecimal.valueOf(Double.MAX_VALUE).multiply(BigDecimal.valueOf(2)).toString(), DataType.Name.DECIMAL); assertThat(bigDecimal).isInstanceOf(BigDecimal.class) .isEqualTo(BigDecimal.valueOf(Double.MAX_VALUE).multiply(BigDecimal.valueOf(2))); bigDecimal = EventParser.parseValue( BigDecimal.valueOf(Double.MIN_VALUE).multiply(BigDecimal.valueOf(2)).toString(), DataType.Name.DECIMAL); assertThat(bigDecimal).isInstanceOf(BigDecimal.class) .isEqualTo(BigDecimal.valueOf(Double.MIN_VALUE).multiply(BigDecimal.valueOf(2))); bigDecimal = EventParser.parseValue(" 1 2 ", DataType.Name.DECIMAL); assertThat(bigDecimal).isInstanceOf(BigDecimal.class).isEqualTo(BigDecimal.valueOf(12)); Object string = EventParser.parseValue("string", DataType.Name.TEXT); assertThat(string).isInstanceOf(String.class).isEqualTo("string"); Object bool = EventParser.parseValue("true", DataType.Name.BOOLEAN); assertThat(bool).isInstanceOf(Boolean.class).isEqualTo(true); Object addr = EventParser.parseValue("192.168.1.1", DataType.Name.INET); assertThat(addr).isInstanceOf(InetAddress.class).isEqualTo(InetAddress.getByName("192.168.1.1")); UUID randomUUID = UUID.randomUUID(); Object uuid = EventParser.parseValue(randomUUID.toString(), DataType.Name.UUID); assertThat(uuid).isInstanceOf(UUID.class).isEqualTo(randomUUID); }
From source file:edu.scripps.fl.curves.plot.CurvePlot.java
public void addCurveMeanAndStdDev(Curve curve, FitFunction fitFunction, String description) { double min = Double.MAX_VALUE, max = Double.MIN_VALUE; MultiValueMap validMap = new MultiValueMap(); MultiValueMap invalidMap = new MultiValueMap(); // group each concentration in a hash, average, then add point for (int ii = 0; ii < curve.getConcentrations().size(); ii++) { Double c = curve.getConcentrations().get(ii); Double r = curve.getResponses().get(ii); if (curve.getMask().get(ii)) validMap.put(c, r);// w w w.java 2 s .c om else invalidMap.put(c, r); min = Math.min(min, c); max = Math.max(max, c); } addCurve(curve, getSeries(validMap, description), getSeries(invalidMap, ""), fitFunction, min, max); }
From source file:org.pentaho.platform.uifoundation.chart.DialWidgetDefinition.java
/** * TODO PROBLEM HERE! If you use this constructor, the XML schema for the chart attributes is different than if * you use the constructor with the arguments public DialWidgetDefinition( Document document, double value, int * width, int height, IPentahoSession session). This constructor expects the chart attribute nodes to be children * of the <chart-attributes> node, whereas the latter constructor expects the attributes to be children of a * <dial> node. This does not help us with our parity situation, and should be deprecated and reconciled. * //from www . java2 s.c o m * @param data * @param byRow * @param chartAttributes * @param width * @param height * @param session */ public DialWidgetDefinition(final IPentahoResultSet data, final boolean byRow, final Node chartAttributes, final int width, final int height, final IPentahoSession session) { this(0.0, Double.MIN_VALUE, Double.MAX_VALUE, false); attributes = chartAttributes; if (data != null) { if (byRow) { setDataByRow(data); } else { setDataByColumn(data); } } // set legend font setLegendFont(chartAttributes.selectSingleNode(ChartDefinition.LEGEND_FONT_NODE_NAME)); // set legend border visible setLegendBorderVisible(chartAttributes.selectSingleNode(ChartDefinition.DISPLAY_LEGEND_BORDER_NODE_NAME)); // set the alfa layers Node backgroundAlphaNode = chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME); Node foregroundAlphaNode = chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME); if (backgroundAlphaNode != null) { setBackgroundAlpha(chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME)); } if (foregroundAlphaNode != null) { setForegroundAlpha(chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME)); } DialWidgetDefinition.createDial(this, chartAttributes, width, height, session); }
From source file:outlineDescriptor.CellArray.java
/** * Normalizes bin data within this array so that they range from 0 to 1 *//*from w w w.ja v a 2 s. c om*/ public void normalizeBins() { double constant; double max = Double.MIN_VALUE; for (int x = 0; x < columnDimension; x++) { for (int y = 0; y < rowDimension; y++) { double[] bins = array[x][y].getBins(); for (double bin : bins) { max = Math.max(bin, max); } } } constant = 1 / max; for (int x = 0; x < columnDimension; x++) { for (int y = 0; y < rowDimension; y++) { double[] bins = array[x][y].getBins(); for (int i = 0; i < bins.length; i++) { double bin = bins[i]; bins[i] = bin * constant; } array[x][y].setBins(bins); } } }
From source file:com.github.cambierr.lorawanpacket.semtech.Txpk.java
private Txpk() { imme = false;/*from w ww .j av a2 s . c o m*/ tmst = Integer.MIN_VALUE; time = null; freq = Double.MIN_VALUE; rfch = Integer.MIN_VALUE; powe = Integer.MIN_VALUE; modu = null; datr = null; codr = null; fdev = Integer.MIN_VALUE; ipol = false; prea = Integer.MIN_VALUE; size = Integer.MIN_VALUE; data = null; ncrc = false; }
From source file:mt.Tracking.java
public static ArrayList<Pair<Integer, Double>> loadsimple(final File file) { final ArrayList<Pair<Integer, Double>> points = new ArrayList<Pair<Integer, Double>>(); final ArrayList<Pair<Integer, Double>> normalpoints = new ArrayList<Pair<Integer, Double>>(); try {//from w w w.jav a 2 s. c o m BufferedReader in = Util.openFileRead(file); while (in.ready()) { String line = in.readLine().trim(); while (line.contains("\t\t")) line = line.replaceAll("\t\t", "\t"); if (line.length() >= 3 && line.matches("[0-9].*")) { final String[] split = line.trim().split("\t"); final int frame = (int) Double.parseDouble(split[0]); final double length = Double.parseDouble(split[1]); points.add(new ValuePair<Integer, Double>(frame, length)); } } } catch (Exception e) { e.printStackTrace(); return null; } double maxlength = Double.MIN_VALUE; for (Pair<Integer, Double> point : points) { double length = point.getB(); if (length > maxlength) maxlength = length; } for (Pair<Integer, Double> point : points) { Pair<Integer, Double> newpoint = new ValuePair<Integer, Double>(point.getA() / 10, point.getB() / maxlength); normalpoints.add(newpoint); } return normalpoints; }
From source file:com.taobao.weex.devtools.json.ObjectMapperTest.java
@Test public void testObjectToPrimitive() throws JSONException { ArrayOfPrimitivesContainer container = new ArrayOfPrimitivesContainer(); ArrayList<Object> primitives = container.primitives; primitives.add(Long.MIN_VALUE); primitives.add(Long.MAX_VALUE); primitives.add(Integer.MIN_VALUE); primitives.add(Integer.MAX_VALUE); primitives.add(Float.MIN_VALUE); primitives.add(Float.MAX_VALUE); primitives.add(Double.MIN_VALUE); primitives.add(Double.MAX_VALUE); String json = mObjectMapper.convertValue(container, JSONObject.class).toString(); JSONObject obj = new JSONObject(json); JSONArray array = obj.getJSONArray("primitives"); ArrayList<Object> actual = new ArrayList<>(); for (int i = 0, N = array.length(); i < N; i++) { actual.add(array.get(i));// w ww . j a va 2s . c o m } assertEquals(primitives.toString(), actual.toString()); }
From source file:org.yccheok.jstock.charting.Utils.java
/** * Returns weekly chart data based on given stock history server. * //from ww w. jav a2 s . co m * @param stockHistoryServer the stock history server * @return list of weekly chart data */ public static List<ChartData> getWeeklyChartData(StockHistoryServer stockHistoryServer) { final int days = stockHistoryServer.size(); Calendar prevCalendar = null; List<ChartData> chartDatas = new ArrayList<ChartData>(); double prevPrice = 0; double openPrice = 0; double lastPrice = 0; double highPrice = Double.MIN_VALUE; double lowPrice = Double.MAX_VALUE; long volume = 0; long timestamp = 0; int count = 0; for (int i = 0; i < days; i++) { // First, determine the current data is same week as the previous // data. boolean isSameWeek = false; final long t = stockHistoryServer.getTimestamp(i); Stock stock = stockHistoryServer.getStock(t); final Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(t); if (prevCalendar != null) { int weekOfYear = calendar.get(Calendar.WEEK_OF_YEAR); int prevWeekOfYear = prevCalendar.get(Calendar.WEEK_OF_YEAR); // Is this the same week? isSameWeek = (weekOfYear == prevWeekOfYear); } else { // First time for us to enter this for loop. isSameWeek = true; openPrice = stock.getOpenPrice(); prevPrice = stock.getPrevPrice(); } if (isSameWeek == false) { // This is a new week. There must be data for previous week. assert (count > 0); ChartData chartData = ChartData.newInstance(prevPrice, openPrice, lastPrice / count, // Average last price. highPrice, lowPrice, volume / count, // Average volume. timestamp); chartDatas.add(chartData); // First day of the week. prevPrice = stock.getPrevPrice(); openPrice = stock.getOpenPrice(); lastPrice = stock.getLastPrice(); highPrice = stock.getHighPrice(); lowPrice = stock.getLowPrice(); volume = stock.getVolume(); timestamp = stock.getTimestamp(); count = 1; } else { // We will not update prevPrice and openPrice. They will remain // as the first day of the week's. lastPrice += stock.getLastPrice(); highPrice = Math.max(highPrice, stock.getHighPrice()); lowPrice = Math.min(lowPrice, stock.getLowPrice()); volume += stock.getVolume(); timestamp = stock.getTimestamp(); count++; } prevCalendar = calendar; } // Is there any data which is not being inserted yet? if (count > 0) { ChartData chartData = ChartData.newInstance(prevPrice, openPrice, lastPrice / count, highPrice, lowPrice, volume / count, timestamp); chartDatas.add(chartData); } return chartDatas; }
From source file:ubic.gemma.analysis.preprocess.OutlierDetectionServiceImpl.java
@Override public Collection<OutlierDetails> identifyOutliers(ExpressionExperiment ee, DoubleMatrix<BioAssay, BioAssay> cormat, int quantileThreshold, double fractionThreshold) { /*/*from w w w. j a v a 2s .c o m*/ * Raymond's algorithm: "A sample which has a correlation of less than a threshold with more than 80% of the * other samples. The threshold is just the first quartile of sample correlations." */ /* * First pass: Determine the threshold (quartile?) */ assert cormat.rows() == cormat.columns(); DoubleArrayList cors = new DoubleArrayList(); for (int i = 0; i < cormat.rows(); i++) { for (int j = i + 1; j < cormat.rows(); j++) { double d = cormat.get(i, j); cors.add(d); } } /* * TODO sanity checks to make sure correlations aren't all the same, etc. */ DoubleArrayList ranks = Rank.rankTransform(cors); assert ranks != null; int desiredQuantileIndex = (int) Math.ceil(cors.size() * (quantileThreshold / 100.0)); double valueAtDesiredQuantile = Double.MIN_VALUE; for (int i = 0; i < ranks.size(); i++) { if (ranks.get(i) == desiredQuantileIndex) { valueAtDesiredQuantile = cors.get(i); } } if (valueAtDesiredQuantile == Double.MIN_VALUE) { throw new IllegalStateException("Could not determine desired quantile"); } log.info("Threshold correlation is " + String.format("%.2f", valueAtDesiredQuantile)); // second pass; for each sample, how many correlations does it have which are below the selected quantile. Collection<OutlierDetails> outliers = new HashSet<OutlierDetails>(); for (int i = 0; i < cormat.rows(); i++) { BioAssay ba = cormat.getRowName(i); int countBelow = 0; for (int j = 0; j < cormat.rows(); j++) { double cor = cormat.get(i, j); if (cor < valueAtDesiredQuantile) { countBelow++; } } // if it has more than the threshold fraction of low correlations, we flag it. if (countBelow > fractionThreshold * cormat.columns()) { OutlierDetails outlier = new OutlierDetails(ba, countBelow / (double) (cormat.columns() - 1), valueAtDesiredQuantile); outliers.add(outlier); } } if (outliers.size() == 0) { log.info("No outliers for " + ee); return outliers; } /* * TODO additional checks: does it 'agree' with replicates of the same condition? (esp. if we didn't work with * residuals) */ return outliers; }
From source file:mastermind.RandomGenerator.java
public double getRandomDouble() { return getRandomDouble(Double.MIN_VALUE, Double.MAX_VALUE); }