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:fr.amap.lidar.amapvox.commons.GTheta.java
/** * <p>Get the transmittance from the specified angle (radians or degrees) and the specified Leaf Angle Distribution.</p> * 0 is vertical, 90 is horizontal (zenithal angle, measured from vertical). * @param theta Angle/*from ww w .j av a 2 s .c o m*/ * @param degrees true if the given angle is in degrees, false otherwise * @return directional transmittance (GTheta) */ public double getGThetaFromAngle(double theta, boolean degrees) { if (degrees) { if (theta > 90) { //get an angle between 0 and 90 theta = 180 - theta; } } else { if (theta > (Math.PI / 2.0)) { //get an angle between 0 and pi/2 theta = Math.PI - theta; } } if (transmittanceFunctions != null && !isBuildingTable) { //a table was built int indice = 0; if (degrees) { indice = (int) (theta / res); } else { indice = (int) (Math.toDegrees(theta) / res); } if (indice >= transmittanceFunctions.length) { indice = transmittanceFunctions.length - 1; } else if (indice < 0) { indice = 0; } return transmittanceFunctions[indice]; } else { //no table was built, get transmittance on the fly if (pdfArray == null) { setupDensityProbabilityArray(DEFAULT_STEP_NUMBER); } if (distribution.getType() == SPHERIC) { return 0.5; //the result for spherical distribution is always 0.5, saving processing time } else { if (degrees) { theta = Math.toRadians(theta); } if (theta == 0) { theta = Double.MIN_VALUE; } if (theta >= Math.PI / 2.0) { theta = (Math.PI / 2.0) - 0.00001; } UnivariateFunction function1 = new CustomFunction1(theta); UnivariateFunction function2 = new CustomFunction2(theta); TrapezoidIntegrator integrator = new TrapezoidIntegrator(); double sum = 0; for (int j = 0; j < nbIntervals; j++) { double thetaL = (serie_angulaire[j] + serie_angulaire[j + 1]) / 2.0d; double Fi = (pdfArray[j]) / SOM; double cotcot = Math.abs(1 / (Math.tan(theta) * Math.tan(thetaL))); double Hi; if (cotcot > 1 || Double.isInfinite(cotcot)) { Hi = integrator.integrate(10000, function1, serie_angulaire[j], serie_angulaire[j + 1]); } else { Hi = integrator.integrate(10000, function2, serie_angulaire[j], serie_angulaire[j + 1]); //System.out.println("nb evaluations: " + integrator.getEvaluations()); } double Gi = Fi * Hi / ((Math.PI / 2) / (double) serie_angulaire.length); //because we need the average value not the actual integral value!!!! sum += Gi; } return sum; } } }
From source file:sadl.integration.MonteCarloIntegration.java
private Pair<Double, Double> findExtreme(ContinuousDistribution d, double xMin, double xMax, double stepResolution) { double yMin = Double.MAX_VALUE; double yMax = Double.MIN_VALUE; for (double i = xMin; i <= xMax; i += stepResolution) { final double pdfValue = d.pdf(i); yMin = Math.min(yMin, pdfValue); yMax = Math.max(yMax, pdfValue); }/*from ww w. j av a 2 s .c o m*/ return Pair.of(new Double(yMin), new Double(yMax)); }
From source file:com.offbynull.voip.kademlia.GraphHelper.java
private void setupRoutingTreeGraph(Context ctx) { IdXorMetricComparator idComparator = new IdXorMetricComparator(baseId); Map<BitString, Point> processedPrefixes = new HashMap<>(); // prefix -> position on graph addRootToGraph(ctx, processedPrefixes); routeTreePrefixToIds.put(BitString.createFromString(""), new TreeSet<>(idComparator)); // special case for empty prefix LinkedList<BitString> tempPrefixes = new LinkedList<>(routerBucketPrefixes); double maxYPosition = Double.MIN_VALUE; while (true) { // Get next prefixes ArrayList<BitString> nextLevelPrefixes = removePrefixesForNextLevel(tempPrefixes); if (nextLevelPrefixes.isEmpty()) { break; }/*from w w w.ja v a 2 s . com*/ // Find parent int bitLengthOfNextLevelPrefixes = nextLevelPrefixes.get(0).getBitLength(); BitString parentPrefix = getParentPrefix(processedPrefixes.keySet(), nextLevelPrefixes.get(0)); Point parentPoint = processedPrefixes.get(parentPrefix); // Calculate number of bits after parent prefix (the bits to display) int newBitsOffset = parentPrefix.getBitLength(); int newBitsLength = bitLengthOfNextLevelPrefixes - parentPrefix.getBitLength(); // Calculate starting x and y positions double numBranches = 1 << newBitsLength; double missingBitLength = baseId.getBitLength() - bitLengthOfNextLevelPrefixes; double ySpreadAtLevel = Y_SPREAD * (missingBitLength + 1.0); double xSpreadAtLevel = X_SPREAD * (missingBitLength + 1.0); double yPosition = parentPoint.y + ySpreadAtLevel; // nodes right below the parent double xPosition = parentPoint.x - xSpreadAtLevel * (numBranches - 1.0) / 2.0; // nodes x-centered on parent // special-case for netLevelPrefixes where prefix for our baseId doesn't exist... this is the branch that falls further down // // e.g. If you're 000, prefixes will be 1, 01, 001, 000... but for each of those you'll want to show the falling-thru prefix as // well.. for example... // // /\ // (NOT STATED IN PREFIXES) 0 / \ 1 // /\ // (NOT STATED IN PREFIXES) 00 / \ 01 // /\ // (EXISTS IN PREFIXES) 000 / \ 001 // // Note that 000 exists, but 00 and 0 don't. BitString baseIdPortion = baseId.getBitString().getBits(0, bitLengthOfNextLevelPrefixes); if (!nextLevelPrefixes.contains(baseIdPortion)) { nextLevelPrefixes.add(baseIdPortion); } // Make sure smallest branch is always to the left-most by sorting Collections.sort(nextLevelPrefixes, (x, y) -> Long.compare(x.getBitsAsLong(newBitsOffset, newBitsLength), y.getBitsAsLong(newBitsOffset, newBitsLength))); // Add prefixes from routing tree for (BitString nextPrefix : nextLevelPrefixes) { routeTreePrefixToIds.put(nextPrefix, new TreeSet<>(idComparator)); addPrefixToGraph(nextPrefix, newBitsOffset, newBitsLength, xPosition, yPosition, ctx, parentPrefix, processedPrefixes); xPosition += xSpreadAtLevel; } // Update max Y position maxYPosition = Math.max(maxYPosition, yPosition); } }
From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java
@SuppressWarnings("deprecation") @Override/*from ww w . j a v a2 s .c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!Const.IS_DEBUG) { Crittercism.init(getApplicationContext(), Const.CRITTERCISM_APP_ID); } requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); activityHelper = ActivityHelper.createInstance(this); parkingApp = (ParkingApp) getApplicationContext(); parkingApp.updateUiLanguage(); /** * Display the GPLv3 licence */ if (!EulaHelper.hasAcceptedEula(this)) { if (ConnectionHelper.hasConnection(this)) { EulaHelper.showEula(false, this); } else { setContentView(R.layout.activity_no_connection); setSupportProgressBarIndeterminateVisibility(Boolean.FALSE); return; } } hasLoadedData = parkingApp.hasLoadedData(); if (!hasLoadedData) { hasLoadedData = true; // The service runs in the background with no listener Intent intent = new Intent(Intent.ACTION_SYNC, null, getApplicationContext(), SyncService.class); intent.putExtra(Const.INTENT_EXTRA_SERVICE_LOCAL, false); intent.putExtra(Const.INTENT_EXTRA_SERVICE_REMOTE, true); startService(intent); } isPlayservicesOutdated = (GooglePlayServicesUtil .isGooglePlayServicesAvailable(getApplicationContext()) != ConnectionResult.SUCCESS); if (isPlayservicesOutdated) { disableLocationUpdates(); isCenterOnMyLocation = false; setContentView(R.layout.activity_playservices_update); setSupportProgressBarIndeterminateVisibility(Boolean.FALSE); return; } else { setContentView(R.layout.activity_main); setSupportProgressBarIndeterminateVisibility(Boolean.FALSE); } // Set the layout containing the two fragments // Get the fragments FragmentManager fm = getSupportFragmentManager(); mMapFragment = (MapFragment) fm.findFragmentByTag(Const.TAG_FRAGMENT_MAP); mFavoritesFragment = (FavoritesFragment) fm.findFragmentByTag(Const.TAG_FRAGMENT_FAVORITES); // Create the actionbar tabs final ActionBar ab = getSupportActionBar(); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ab.addTab(ab.newTab().setText(R.string.tab_map).setTabListener(this).setTag(Const.TAG_TABS_MAP)); ab.addTab( ab.newTab().setText(R.string.tab_favorites).setTabListener(this).setTag(Const.TAG_TABS_FAVORITES)); initLocation = null; double latitude = getIntent().getDoubleExtra(Const.INTENT_EXTRA_GEO_LAT, Double.MIN_VALUE); double longitude = getIntent().getDoubleExtra(Const.INTENT_EXTRA_GEO_LNG, Double.MIN_VALUE); if (Double.compare(latitude, Double.MIN_VALUE) != 0 && Double.compare(latitude, Double.MIN_VALUE) != 0) { initLocation = new Location(Const.LOCATION_PROVIDER_INTENT); initLocation.setLatitude(latitude); initLocation.setLongitude(longitude); isCenterOnMyLocation = false; } else { isCenterOnMyLocation = true; // Initialize the displayed values. This is not done when // MainActivity is called from Details activity, to keep the same // Calendar. parkingApp.resetParkingCalendar(); } updateParkingTimeTitle(); updateParkingDateButton(); updateParkingTimeButton(); updateParkingDurationButton(); mFavoritesFragment.refreshList(); mDrawer = (SlidingDrawer) findViewById(R.id.drawer_time); mDrawer.animateOpen(); }
From source file:org.broadinstitute.gatk.engine.recalibration.RecalDatumNode.java
/** * The maximum penalty among all nodes//from w w w .ja va2 s. c om * @return */ public double maxPenalty(final boolean leafOnly) { double max = !leafOnly || isLeaf() ? getPenalty() : Double.MIN_VALUE; for (final RecalDatumNode<T> sub : subnodes) max = Math.max(max, sub.maxPenalty(leafOnly)); return max; }
From source file:ubic.gemma.analysis.preprocess.ProcessedExpressionDataVectorCreateHelperServiceImpl.java
/** * @param intensities/*from w w w . j a v a2 s . c o m*/ * @return */ private DoubleArrayList getRanks(ExpressionDataDoubleMatrix intensities, ProcessedExpressionDataVectorDao.RankMethod method) { log.debug("Getting ranks"); DoubleArrayList result = new DoubleArrayList(intensities.rows()); for (ExpressionDataMatrixRowElement de : intensities.getRowElements()) { double[] rowObj = ArrayUtils.toPrimitive(intensities.getRow(de.getDesignElement())); double valueForRank = Double.MIN_VALUE; if (rowObj != null) { DoubleArrayList row = new DoubleArrayList(rowObj); switch (method) { case max: valueForRank = DescriptiveWithMissing.max(row); break; case mean: valueForRank = DescriptiveWithMissing.mean(row); break; } } result.add(valueForRank); } return Rank.rankTransform(result); }
From source file:userinterface.graph.PrismErrorRenderer.java
/** * This method is needed for displaying the graph in the correct range (not too zoomed out or in) * @param dataset the dataset which needs to be plotted * @author Muhammad Omer Saeed// w ww . ja v a 2 s. co m */ public Range findRangeBounds(XYDataset dataset) { if (dataset != null) { XYSeriesCollection collection = (XYSeriesCollection) dataset; List<XYSeries> series = collection.getSeries(); double max = Double.MIN_VALUE, min = Double.MAX_VALUE; for (XYSeries s : series) { for (int i = 0; i < s.getItemCount(); i++) { PrismXYDataItem item = (PrismXYDataItem) s.getDataItem(i); if ((item.getYValue() - item.getError()) < min) { min = (item.getYValue() - item.getError()); } if ((item.getYValue() + item.getError()) > max) { max = (item.getYValue() + item.getError()); } } } if (max == Double.MIN_VALUE && min == Double.MAX_VALUE) { return null; } else return new Range(min, max); } else { return null; } }
From source file:gda.device.detector.mythen.data.MythenDataFileUtils.java
public static double[][][] binMythenData(double[][][] input, double binSize) { // Find min/max angle double minAngle = Double.MAX_VALUE; double maxAngle = Double.MIN_VALUE; for (double[][] dataset : input) { for (double[] channel : dataset) { minAngle = Math.min(channel[0], minAngle); maxAngle = Math.max(channel[0], maxAngle); }//from ww w .j a va 2 s .c o m } // Determine bins final int minBinNum = (int) Math.floor(minAngle / binSize); final int maxBinNum = (int) Math.ceil(maxAngle / binSize); final int numBins = maxBinNum - minBinNum + 1; final int numDatasets = input.length; // Create binned data array double[][][] binnedData = new double[numDatasets][][]; // Create array for each dataset for (int dataset = 0; dataset < numDatasets; dataset++) { binnedData[dataset] = new double[numBins][]; } // Within each dataset, create array for each bin // Iterate through bins first, then datasets, for efficiency (only calculate a bin's start angle once) for (int bin = 0; bin < numBins; bin++) { final double binStartAngle = (bin + minBinNum) * binSize; for (int dataset = 0; dataset < numDatasets; dataset++) { binnedData[dataset][bin] = new double[] { binStartAngle, 0 }; } } // Bin data for (int dataset = 0; dataset < numDatasets; dataset++) { // logger.debug(String.format("Dataset %d of %d", dataset+1, numDatasets)); final double[][] inputDataset = input[dataset]; for (double[] channel : inputDataset) { final double angle = channel[0]; final int binNumForAngle = (int) Math.floor(angle / binSize); final int binIndexForAngle = binNumForAngle - minBinNum; final double[] binForAngle = binnedData[dataset][binIndexForAngle]; final double count = channel[1]; // logger.debug(String.format("%.16f %.1f = %.16f => %d/%d\tcount=%.0f", angle, binSize, // (angle/binSize), binNumForAngle, binIndexForAngle, count)); binForAngle[1] = Math.max(binForAngle[1], count); } } return binnedData; }
From source file:playground.johannes.snowball2.GraphStatistic.java
protected double calcGammaExponent(double[] values, double[] weights, double fixedBinSize, double minVal) { /*//from w w w .ja v a2 s . c o m * (1) Determine probability distribution. */ int numBins = 1000;//values.length / 10; double min = StatUtils.min(values); double max = StatUtils.max(values); double binSize; if (fixedBinSize > 0) { binSize = fixedBinSize; numBins = (int) Math.ceil((max - min) / binSize); } else binSize = (max - min) / (double) numBins; double[] bins = new double[numBins + 1]; for (int i = 0; i < values.length; i++) { int idx = (int) Math.floor((values[i] - min) / binSize); bins[idx] += weights[i]; } /* * (2) Get value with the highest probability. */ int maxHeightBinIdx = -1; double maxHeight = Double.MIN_VALUE; for (int i = 0; i < bins.length; i++) { if (maxHeight < bins[i]) { maxHeight = bins[i]; maxHeightBinIdx = i; } } double minPowerLawVal = (maxHeightBinIdx * binSize) + min; if (minPowerLawVal == 0) minPowerLawVal = Double.MIN_VALUE; //======================================================= if (minVal > 0) minPowerLawVal = minVal; /* * (3) Calculate gamma with maximum likelihood estimator. */ double logsum = 0; double wsum = 0; int count = 0; for (int i = 0; i < values.length; i++) { if (values[i] >= minPowerLawVal) { logsum += Math.log((values[i] / minPowerLawVal)) * weights[i]; wsum += weights[i]; // wsum++; count++; } } System.out.println("Count = " + count + "; wsum = " + wsum); return 1 + (wsum / logsum); }
From source file:com.act.lcms.db.analysis.WaveformAnalysis.java
/** * This function returns the maximum noise among a map of ion to list of spectra * @param spectra A map of ion to spectrum * @return The maximum noise of the map/*from w w w .ja v a2s . com*/ */ public static Double maxNoiseOfSpectra(Map<String, List<XZ>> spectra) { Double maxNoise = Double.MIN_VALUE; for (Map.Entry<String, List<XZ>> ionToSpectrum : spectra.entrySet()) { maxNoise = Math.max(maxNoise, noiseOfSpectrum(ionToSpectrum.getValue())); } return maxNoise; }