List of usage examples for java.lang Double MAX_VALUE
double MAX_VALUE
To view the source code for java.lang Double MAX_VALUE.
Click Source Link
From source file:org.pentaho.platform.uifoundation.chart.DialWidgetDefinition.java
/** * TODO: PROBLEM HERE! See the note on the constructor above. * /*from ww w . ja v a 2 s. com*/ * @param document * @param value * @param width * @param height * @param session */ public DialWidgetDefinition(final Document document, final double value, final int width, final int height, final IPentahoSession session) { this(value, Double.MIN_VALUE, Double.MAX_VALUE, false); // get the dial node from the document attributes = document.selectSingleNode("//dial"); //$NON-NLS-1$ deriveMinMax(value); // create the dial definition object DialWidgetDefinition.createDial(this, attributes, width, height, session); }
From source file:edu.oregonstate.eecs.mcplan.ml.GaussianMixtureModel.java
private void fixSigma(final int cluster) { // final RealMatrix correction = Sigma_[cluster].copy(); // correction.subtract( Sigma_[cluster].transpose() ); // correction.scalarMultiply( 0.5 ); // Sigma_[cluster] = Sigma_[cluster].subtract( correction ); // System.out.println( "\tafter correction: " + Sigma_[cluster] ); RealMatrix id = MatrixUtils.createRealIdentityMatrix(d_); double max_diag = -Double.MAX_VALUE; for (int i = 0; i < d_; ++i) { final double d = Math.abs(Sigma_[cluster].getEntry(i, i)); if (d > max_diag) { max_diag = d;/*w ww . j a va2 s . c om*/ } } // System.out.println( "\tmax_diag = " + max_diag ); // FIXME: There's no way to choose the right magnitude for the correction here. if (max_diag == 0.0) { max_diag = 1.0; } // assert( max_diag > 0 ); id = id.scalarMultiply(0.01 * max_diag); // System.out.println( "\tid = " + id ); // System.out.println( "\tbefore correction: " + Sigma_[cluster] ); Sigma_[cluster] = Sigma_[cluster].add(id); // System.out.println( "\tafter correction: " + Sigma_[cluster] ); }
From source file:com.velonuboso.made.core.common.Helper.java
/** * returns the minimum value os a given array and size. * * @param data the array of data//from w w w. j a va2 s.com * @param length the searchable length * @return the minimum value. Double.MAX_VALUE on zero length */ public static double getMin(double[] data, int length) { if (length > data.length) { length = data.length; } if (length == 0) { return Double.MAX_VALUE; } double min = data[0]; for (int i = 1; i < length; i++) { double a = data[i]; if (a < min) { min = a; } } return min; }
From source file:com.nridge.core.base.field.data.DataFieldAnalyzer.java
/** * Returns a data bag of fields describing the scanned value data. * The bag will contain the field name, derived type, populated * count, null count and a sample count of values (with overall * percentages) that repeated most often. * * @param aSampleCount Identifies the top count of values. * * @return Data bag of analysis details. *///w ww .j ava 2s . c o m public DataBag getDetails(int aSampleCount) { Date dateValue; Integer valueCount; String fieldName, fieldTitle, dataValue; Double valuePercentage, minValue, maxValue; Field.Type fieldType = getType(); int uniqueValues = mValueCount.size(); DataBag detailsBag = new DataBag(mName); detailsBag.add(new DataTextField("name", "Name", mName)); detailsBag.add(new DataTextField("type", "Type", Field.typeToString(fieldType))); detailsBag.add(new DataIntegerField("total_count", "Total Count", mTotalValues)); detailsBag.add(new DataIntegerField("null_count", "Null Count", mNullCount)); detailsBag.add(new DataIntegerField("unique_count", "Unique Count", uniqueValues)); // Create a table from the values map and use sorting to get our top sample size. DataTable valuesTable = new DataTable(mName); valuesTable.add(new DataTextField("value", "Value")); valuesTable.add(new DataIntegerField("count", "Count")); valuesTable.add(new DataDoubleField("percentage", "Percentage")); minValue = Double.MAX_VALUE; maxValue = Double.MIN_VALUE; for (Map.Entry<String, Integer> entry : mValueCount.entrySet()) { valuesTable.newRow(); dataValue = entry.getKey(); valueCount = entry.getValue(); if (mTotalValues == 0) valuePercentage = 0.0; else valuePercentage = valueCount.doubleValue() / mTotalValues * 100.0; valuesTable.newRow(); valuesTable.setValueByName("value", dataValue); valuesTable.setValueByName("count", valueCount); valuesTable.setValueByName("percentage", String.format("%.2f", valuePercentage)); if (Field.isText(fieldType)) { minValue = Math.min(minValue, dataValue.length()); maxValue = Math.max(maxValue, dataValue.length()); } else if (Field.isNumber(fieldType)) { minValue = Math.min(minValue, Double.parseDouble(dataValue)); maxValue = Math.max(maxValue, Double.parseDouble(dataValue)); } else if (Field.isDateOrTime(fieldType)) { // While we are decomposing the date to milliseconds of time, you can do a Date(milliseconds) // reconstruction. dateValue = DatUtl.detectCreateDate(dataValue); if (dataValue != null) { minValue = Math.min(minValue, dateValue.getTime()); maxValue = Math.max(maxValue, dateValue.getTime()); } } valuesTable.addRow(); } valuesTable.sortByColumn("count", Field.Order.DESCENDING); if (Field.isBoolean(fieldType)) { detailsBag.add(new DataTextField("minimum", "Minimum", StrUtl.STRING_FALSE)); detailsBag.add(new DataTextField("maximum", "Maximum", StrUtl.STRING_TRUE)); } else if (Field.isDateOrTime(fieldType)) { detailsBag.add(new DataTextField("minimum", "Minimum", Field.dateValueFormatted(new Date(minValue.longValue()), Field.FORMAT_DATETIME_DEFAULT))); detailsBag.add(new DataTextField("maximum", "Maximum", Field.dateValueFormatted(new Date(maxValue.longValue()), Field.FORMAT_DATETIME_DEFAULT))); } else { detailsBag.add(new DataTextField("minimum", "Minimum", String.format("%.2f", minValue))); detailsBag.add(new DataTextField("maximum", "Maximum", String.format("%.2f", maxValue))); } // Create columns for the top sample sizes (value, matching count, matching percentage) int adjCount = Math.min(aSampleCount, valuesTable.rowCount()); for (int row = 0; row < adjCount; row++) { fieldName = String.format("value_%02d", row + 1); fieldTitle = String.format("Value %02d", row + 1); dataValue = valuesTable.getValueByName(row, "value"); detailsBag.add(new DataTextField(fieldName, fieldTitle, dataValue)); fieldName = String.format("count_%02d", row + 1); fieldTitle = String.format("Count %02d", row + 1); detailsBag.add(new DataIntegerField(fieldName, fieldTitle, valuesTable.getValueByName(row, "count"))); fieldName = String.format("percent_%02d", row + 1); fieldTitle = String.format("Percent %02d", row + 1); detailsBag .add(new DataDoubleField(fieldName, fieldTitle, valuesTable.getValueByName(row, "percentage"))); } return detailsBag; }
From source file:com.mobiperf.measurements.PingTask.java
private MeasurementResult constructResult(ArrayList<Double> rrtVals, double packetLoss, int packetsSent, String pingMethod) {//from www. ja v a2s . c o m double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; double mdev, avg, filteredAvg; double total = 0; boolean success = true; if (rrtVals.size() == 0) { return null; } for (double rrt : rrtVals) { if (rrt < min) { min = rrt; } if (rrt > max) { max = rrt; } total += rrt; } avg = total / rrtVals.size(); mdev = Util.getStandardDeviation(rrtVals, avg); filteredAvg = filterPingResults(rrtVals, avg); PhoneUtils phoneUtils = PhoneUtils.getPhoneUtils(); MeasurementResult result = new MeasurementResult(phoneUtils.getDeviceInfo().deviceId, phoneUtils.getDeviceProperty(), PingTask.TYPE, System.currentTimeMillis() * 1000, success, this.measurementDesc); result.addResult("target_ip", targetIp); result.addResult("mean_rtt_ms", avg); result.addResult("min_rtt_ms", min); result.addResult("max_rtt_ms", max); result.addResult("stddev_rtt_ms", mdev); if (filteredAvg != avg) { result.addResult("filtered_mean_rtt_ms", filteredAvg); } result.addResult("packet_loss", packetLoss); result.addResult("packets_sent", packetsSent); result.addResult("ping_method", pingMethod); Logger.i(MeasurementJsonConvertor.toJsonString(result)); return result; }
From source file:adams.data.statistics.StatUtils.java
/** * Returns the (first occurrence of the) index of the cell with the smallest * number. -1 in case of zero-length arrays. * * @param array the array to work on//from w ww. j av a2s . com * @return the index */ public static int minIndex(Number[] array) { int result; int i; double minValue; result = -1; minValue = Double.MAX_VALUE; for (i = 0; i < array.length; i++) { if (array[i].doubleValue() < minValue) { minValue = array[i].doubleValue(); result = i; } } return result; }
From source file:edu.utexas.cs.tactex.MarketManagerService.java
@SuppressWarnings("unchecked") @Override//from w w w . j a va 2 s.com public void initialize(BrokerContext brokerContext) { // NEVER CALL ANY SERVICE METHOD FROM HERE, SINCE THEY ARE NOT GUARANTEED // TO BE initalize()'d. // Exception: it is OK to call configuratorFactory's public // (application-wide) constants this.brokerContext = brokerContext; marketTotalMwh = 0; marketTotalPayments = 0; lastOrder = new HashMap<Integer, Order>(); marketMWh = new double[configuratorFactoryService.CONSTANTS.USAGE_RECORD_LENGTH()]; Arrays.fill(marketMWh, 1e-9); // to avoid 0-division marketPayments = new double[configuratorFactoryService.CONSTANTS.USAGE_RECORD_LENGTH()]; predictedUsage = new double[24][2500]; actualUsage = new double[2500]; orderbooks = new HashMap<Integer, Orderbook>(); maxTradePrice = -Double.MAX_VALUE; minTradePrice = Double.MAX_VALUE; supportingBidGroups = new TreeMap<Integer, ArrayList<PriceMwhPair>>(); dpCache2013 = new DPCache(); shortBalanceTransactionsData = new ArrayList<ChargeMwhPair>(); surplusBalanceTransactionsData = new ArrayList<ChargeMwhPair>(); }
From source file:fr.lig.sigma.astral.gui.graph.sugiyama.SugiyamaLayerStack.java
void xPosUp(int staticIndex, int flexIndex) { List<Node<E>> flex = layers.get(flexIndex); for (int i = flex.size() - 1; i > -1; i--) { Node<E> n = flex.get(i); double min = i > 0 ? flex.get(i - 1).getPos().x + flex.get(i - 1).getSize().x + X_SEP : -Double.MAX_VALUE; double max = i < flex.size() - 1 ? flex.get(i + 1).getPos().x - n.getSize().x - X_SEP : Double.MAX_VALUE; List<Node<E>> neighbors = getConnectedTo(n, staticIndex); double avg = avgX(neighbors); if (!Double.isNaN(avg)) { n.setPos(max(min, min(max, avg - n.getSize().x / 2d)), n.getPos().y); }//from w w w. j a va2 s .c o m } }
From source file:etymology.util.EtyMath.java
public static double getMin(Collection<Double> values) { double min = Double.MAX_VALUE; for (double value : values) { min = Math.min(min, value); }//w w w. ja v a 2s.c om return min; }
From source file:edu.umn.cs.sthadoop.operations.STRangeQuery.java
public static void main(String[] args) throws Exception { // args = new String[7]; // args[0] = "/home/louai/nyc-taxi/yellowIndex"; // args[1] = "/home/louai/nyc-taxi/resultSTRQ"; // args[2] = "shape:edu.umn.cs.sthadoop.core.STPoint"; // args[3] = "rect:-74.98451232910156,35.04014587402344,-73.97936248779295,41.49399566650391"; // args[4] = "interval:2015-01-01,2015-01-02"; // args[5] = "-overwrite"; // args[6] = "-no-local"; // Query for test with output // args = new String[6]; // args[0] = "/home/louai/nyc-taxi/yellowIndex"; // args[1] = "shape:edu.umn.cs.sthadoop.core.STPoint"; // args[2] = "rect:-74.98451232910156,35.04014587402344,-73.97936248779295,41.49399566650391"; // args[3] = "interval:2015-01-01,2015-01-03"; // args[4] = "-overwrite"; // args[5 ] = "-no-local"; final OperationsParams params = new OperationsParams(new GenericOptionsParser(args)); final Path[] paths = params.getPaths(); if (paths.length <= 1 && !params.checkInput()) { printUsage();/*from w w w. j a v a 2 s .c o m*/ System.exit(1); } if (paths.length >= 2 && !params.checkInputOutput()) { printUsage(); System.exit(1); } if (params.get("rect") == null) { String x1 = "-" + Double.toString(Double.MAX_VALUE); String y1 = "-" + Double.toString(Double.MAX_VALUE); String x2 = Double.toString(Double.MAX_VALUE); String y2 = Double.toString(Double.MAX_VALUE); System.out.println(x1 + "," + y1 + "," + x2 + "," + y2); params.set("rect", x1 + "," + y1 + "," + x2 + "," + y2); // System.err.println("You must provide a query range"); // printUsage(); // System.exit(1); } if (params.get("interval") == null) { System.err.println("Temporal range missing"); printUsage(); System.exit(1); } TextSerializable inObj = params.getShape("shape"); if (!(inObj instanceof STPoint) && !(inObj instanceof STRectangle)) { LOG.error("Shape is not instance of STPoint or STRectangle"); printUsage(); System.exit(1); } // Get spatio-temporal slices. List<Path> STPaths = getIndexedSlices(params); final Path outPath = params.getOutputPath(); final Rectangle[] queryRanges = params.getShapes("rect", new Rectangle()); // All running jobs final Vector<Long> resultsCounts = new Vector<Long>(); Vector<Job> jobs = new Vector<Job>(); Vector<Thread> threads = new Vector<Thread>(); long t1 = System.currentTimeMillis(); for (Path stPath : STPaths) { final Path inPath = stPath; for (int i = 0; i < queryRanges.length; i++) { final OperationsParams queryParams = new OperationsParams(params); OperationsParams.setShape(queryParams, "rect", queryRanges[i]); if (OperationsParams.isLocal(new JobConf(queryParams), inPath)) { // Run in local mode final Rectangle queryRange = queryRanges[i]; final Shape shape = queryParams.getShape("shape"); final Path output = outPath == null ? null : (queryRanges.length == 1 ? outPath : new Path(outPath, String.format("%05d", i))); Thread thread = new Thread() { @Override public void run() { FSDataOutputStream outFile = null; final byte[] newLine = System.getProperty("line.separator", "\n").getBytes(); try { ResultCollector<Shape> collector = null; if (output != null) { FileSystem outFS = output.getFileSystem(queryParams); final FSDataOutputStream foutFile = outFile = outFS.create(output); collector = new ResultCollector<Shape>() { final Text tempText = new Text2(); @Override public synchronized void collect(Shape r) { try { tempText.clear(); r.toText(tempText); foutFile.write(tempText.getBytes(), 0, tempText.getLength()); foutFile.write(newLine); } catch (IOException e) { e.printStackTrace(); } } }; } else { outFile = null; } long resultCount = rangeQueryLocal(inPath, queryRange, shape, queryParams, collector); resultsCounts.add(resultCount); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } finally { try { if (outFile != null) outFile.close(); } catch (IOException e) { e.printStackTrace(); } } } }; thread.start(); threads.add(thread); } else { // Run in MapReduce mode Path outTempPath = outPath == null ? null : new Path(outPath, String.format("%05d", i) + "-" + inPath.getName()); queryParams.setBoolean("background", true); Job job = rangeQueryMapReduce(inPath, outTempPath, queryParams); jobs.add(job); } } } while (!jobs.isEmpty()) { Job firstJob = jobs.firstElement(); firstJob.waitForCompletion(false); if (!firstJob.isSuccessful()) { System.err.println("Error running job " + firstJob); System.err.println("Killing all remaining jobs"); for (int j = 1; j < jobs.size(); j++) jobs.get(j).killJob(); System.exit(1); } Counters counters = firstJob.getCounters(); Counter outputRecordCounter = counters.findCounter(Task.Counter.MAP_OUTPUT_RECORDS); resultsCounts.add(outputRecordCounter.getValue()); jobs.remove(0); } while (!threads.isEmpty()) { try { Thread thread = threads.firstElement(); thread.join(); threads.remove(0); } catch (InterruptedException e) { e.printStackTrace(); } } long t2 = System.currentTimeMillis(); System.out.println("QueryPlan:"); for (Path stPath : STPaths) { System.out.println(stPath.getName()); } System.out.println("Time for " + queryRanges.length + " jobs is " + (t2 - t1) + " millis"); System.out.println("Results counts: " + resultsCounts); }