List of usage examples for java.lang Math log10
@HotSpotIntrinsicCandidate public static double log10(double a)
From source file:com.android.stockbrowser.WebStorageSizeManager.java
static long calculateGlobalLimit(long fileSystemSizeBytes, long freeSpaceBytes) { if (fileSystemSizeBytes <= 0 || freeSpaceBytes <= 0 || freeSpaceBytes > fileSystemSizeBytes) { return 0; }//from w ww. jav a 2 s . c o m long fileSystemSizeRatio = 2 << ((int) Math.floor(Math.log10(fileSystemSizeBytes / (1024 * 1024)))); long maxSizeBytes = (long) Math.min(Math.floor(fileSystemSizeBytes / fileSystemSizeRatio), Math.floor(freeSpaceBytes / 2)); // Round maxSizeBytes up to a multiple of 1024KB (but only if // maxSizeBytes > 1MB). long maxSizeStepBytes = 1024 * 1024; if (maxSizeBytes < maxSizeStepBytes) { return 0; } long roundingExtra = maxSizeBytes % maxSizeStepBytes == 0 ? 0 : 1; return (maxSizeStepBytes * ((maxSizeBytes / maxSizeStepBytes) + roundingExtra)); }
From source file:edu.ucuenca.authorsdisambiguation.nwd.NWD.java
public double NGD(String a, String b) throws IOException, SQLException { a = a.trim();/*from w w w. j av a 2s .com*/ b = b.trim(); if (a.compareToIgnoreCase(b) == 0) { return 0; } //double n0 = getResultsCount(""+a+""); //double n1 = getResultsCount(""+b+""); //String c = ""+a+" "+b+""; String _a = "\"" + a + "\"~10"; String _b = "\"" + b + "\"~10"; String c = "\"" + a + " " + b + "\"~50"; if (Cache.getInstance().config.get("relaxMode").getAsBoolean().value()) { _a = "" + a; _b = "" + b; c = a + " " + b; } double n0 = getResultsCount(_a); double n1 = getResultsCount(_b); double n2 = 0; if (n0 == 0 || n1 == 0) { n2 = 0; } else { n2 = getResultsCount(c); } //double m = 5026040.0 * 590; double m = getResultsCount("the"); double distance = 0; int Measure = 0; double l1 = Math.max(Math.log10(n0), Math.log10(n1)) - Math.log10(n2); double l2 = Math.log10(m) - Math.min(Math.log10(n0), Math.log10(n1)); if (Measure == 0) { distance = l1 / l2; } if (Measure == 1) { distance = 1 - (Math.log10(n2) / Math.log10(n0 + n1 - n2)); } if (n0 == 0 || n1 == 0 || n2 == 0) { distance = 1; } //System.out.println("n0="+n0); //System.out.println("n1="+n1); //System.out.println("n2="+n2); //System.out.println(a + "," + b + "=" + distance2); return distance; }
From source file:uk.ac.babraham.FastQC.Modules.KmerContent.java
public boolean raisesError() { if (!calculated) calculateEnrichment();//from w w w .j ava 2 s . c om // We raise an error if the most enriched kmer is seen more than 100 times // more frequently than we expect. if (enrichedKmers.length > 0 && 0 - Math.log10(enrichedKmers[0].pValue()) > ModuleConfig.getParam("kmer", "error")) return true; return false; }
From source file:org.broadinstitute.gatk.engine.recalibration.RecalDatumNode.java
/** * Return a freshly allocated tree where all mergable nodes with < maxPenalty are merged * * Note that nodes must have fixed penalties to this algorithm will fail. * * @param maxPenaltyIn the maximum penalty we are allowed to incur for a merge * @param applyBonferroniCorrection if true, we will adjust penalty by the phred-scaled bonferroni correction * for the size of the initial tree. That is, if there are 10 nodes in the * tree and maxPenalty is 20 we will actually enforce 10^-2 / 10 = 10^-3 = 30 * penalty for multiple testing * @return/*w w w . ja v a2 s .c o m*/ */ public RecalDatumNode<T> pruneToNoMoreThanPenalty(final double maxPenaltyIn, final boolean applyBonferroniCorrection) { RecalDatumNode<T> root = this; final double bonferroniCorrection = 10 * Math.log10(this.size()); final double maxPenalty = applyBonferroniCorrection ? maxPenaltyIn + bonferroniCorrection : maxPenaltyIn; if (applyBonferroniCorrection) logger.info(String.format( "Applying Bonferroni correction for %d nodes = %.2f to initial penalty %.2f for total " + "corrected max penalty of %.2f", this.size(), bonferroniCorrection, maxPenaltyIn, maxPenalty)); while (true) { final Pair<RecalDatumNode<T>, Double> minPenaltyNode = root.getMinPenaltyAboveLeafNode(); if (minPenaltyNode == null || minPenaltyNode.getSecond() > maxPenalty) { // nothing to merge, or the best candidate is above our max allowed if (minPenaltyNode == null) { if (logger.isDebugEnabled()) logger.debug("Stopping because no candidates could be found"); } else { if (logger.isDebugEnabled()) logger.debug("Stopping because node " + minPenaltyNode.getFirst() + " has penalty " + minPenaltyNode.getSecond() + " > max " + maxPenalty); } break; } else { // remove the lowest penalty element, and continue if (logger.isDebugEnabled()) logger.debug("Removing node " + minPenaltyNode.getFirst() + " with penalty " + minPenaltyNode.getSecond()); root = root.removeLowestPenaltyNode(); } } // no more candidates exist with penalty < maxPenalty return root; }
From source file:msi.gaml.operators.Stats.java
@operator(value = "split", can_be_const = true, content_type = IType.LIST, expected_content_type = { IType.INT, IType.FLOAT }, category = { IOperatorCategory.STATISTICAL, IOperatorCategory.CONTAINER }, concept = { IConcept.STATISTIC }) @doc(see = { "split_in", "split_using" }, value = "Splits a list of numbers into n=(1+3.3*log10(elements)) bins. The splitting is strict (i.e. elements are in the ith bin if they are strictly smaller than the ith bound") public static <T extends Number> IList<IList<T>> split(final IScope scope, final IList<T> list) { final int nb = (int) (1 + 3.3 * Math.log10(list.size())); return split_in(scope, list, nb); }
From source file:org.nuxeo.ecm.automation.server.jaxrs.batch.BatchManagerFixture.java
@Test public void testBatchConcurrency() throws Exception { BatchManager bm = Framework.getService(BatchManager.class); // Initialize batches with one file concurrently int nbBatches = 100; String[] batchIds = new String[nbBatches]; ThreadPoolExecutor tpe = new ThreadPoolExecutor(5, 5, 500L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(nbBatches + 1)); for (int i = 0; i < nbBatches; i++) { final int batchIndex = i; tpe.submit(new Runnable() { @Override/*from w w w. j a va 2s . c om*/ public void run() { try { String batchId = bm.initBatch(); bm.addStream(batchId, "0", new ByteArrayInputStream( ("SomeContent_" + batchId).getBytes(StandardCharsets.UTF_8)), "MyBatchFile.txt", "text/plain"); batchIds[batchIndex] = batchId; } catch (IOException e) { fail(e.getMessage()); } } }); } tpe.shutdown(); boolean finish = tpe.awaitTermination(20, TimeUnit.SECONDS); assertTrue("timeout", finish); // Check batches for (String batchId : batchIds) { assertNotNull(batchId); } // Test indexes 0, 9, 99, ..., nbFiles - 1 int nbDigits = (int) (Math.log10(nbBatches) + 1); int divisor = nbBatches; for (int i = 0; i < nbDigits; i++) { int batchIndex = nbBatches / divisor - 1; String batchId = batchIds[batchIndex]; Blob blob = bm.getBlob(batchId, "0"); assertNotNull(blob); assertEquals("MyBatchFile.txt", blob.getFilename()); assertEquals("SomeContent_" + batchId, blob.getString()); divisor = divisor / 10; } // Check storage size TransientStore ts = bm.getTransientStore(); assertTrue(((AbstractTransientStore) ts).getStorageSize() > 12 * nbBatches); // Clean batches for (String batchId : batchIds) { bm.clean(batchId); } assertEquals(ts.getStorageSizeMB(), 0); }
From source file:org.broadinstitute.gatk.tools.walkers.annotator.ExcessHet.java
protected double calculateEH(final VariantContext vc, final GenotypesContext genotypes) { HeterozygosityUtils heterozygosityUtils = new HeterozygosityUtils(RETURN_ROUNDED); final double[] genotypeCountsDoubles = heterozygosityUtils.getGenotypeCountsForRefVsAllAlts(vc, genotypes); sampleCount = heterozygosityUtils.getSampleCount(); final int[] genotypeCounts = new int[genotypeCountsDoubles.length]; for (int i = 0; i < genotypeCountsDoubles.length; i++) { genotypeCounts[i] = (int) genotypeCountsDoubles[i]; }/* w w w .j a v a 2 s . co m*/ double pval = exactTest(genotypeCounts); //If the actual phredPval would be infinity we will probably still filter out just a very large number if (pval == 0) { return Integer.MAX_VALUE; } double phredPval = -10.0 * Math.log10(pval); return phredPval; }
From source file:uk.ac.babraham.FastQC.Modules.KmerContent.java
public boolean raisesWarning() { if (!calculated) calculateEnrichment();// w ww .j av a2 s. c o m // We raise a warning if there are any enriched kmers if (enrichedKmers.length > 0 && 0 - Math.log10(enrichedKmers[0].pValue()) > ModuleConfig.getParam("kmer", "warn")) return true; return false; }
From source file:org.esa.nest.gpf.CosmoSkymedCalibrator.java
public void computeTile(Band targetBand, Tile targetTile, ProgressMonitor pm) throws OperatorException { final Rectangle targetTileRectangle = targetTile.getRectangle(); final int x0 = targetTileRectangle.x; final int y0 = targetTileRectangle.y; final int w = targetTileRectangle.width; final int h = targetTileRectangle.height; Tile sourceRaster1 = null;/* ww w .ja v a 2s.co m*/ ProductData srcData1 = null; ProductData srcData2 = null; Band sourceBand1 = null; final String[] srcBandNames = targetBandNameToSourceBandName.get(targetBand.getName()); if (srcBandNames.length == 1) { sourceBand1 = sourceProduct.getBand(srcBandNames[0]); sourceRaster1 = calibrationOp.getSourceTile(sourceBand1, targetTileRectangle); srcData1 = sourceRaster1.getDataBuffer(); } else { sourceBand1 = sourceProduct.getBand(srcBandNames[0]); final Band sourceBand2 = sourceProduct.getBand(srcBandNames[1]); sourceRaster1 = calibrationOp.getSourceTile(sourceBand1, targetTileRectangle); final Tile sourceRaster2 = calibrationOp.getSourceTile(sourceBand2, targetTileRectangle); srcData1 = sourceRaster1.getDataBuffer(); srcData2 = sourceRaster2.getDataBuffer(); } final Unit.UnitType bandUnit = Unit.getUnitType(sourceBand1); // copy band if unit is phase if (bandUnit == Unit.UnitType.PHASE) { targetTile.setRawSamples(sourceRaster1.getRawSamples()); return; } final String pol = OperatorUtils.getBandPolarization(srcBandNames[0], absRoot).toUpperCase(); double Ks = 1.0; if (pol != null && !pol.isEmpty() && applyConstantCorrection) { Ks = calibrationFactor.get(pol); } final ProductData trgData = targetTile.getDataBuffer(); final TileIndex srcIndex = new TileIndex(sourceRaster1); final TileIndex tgtIndex = new TileIndex(targetTile); final int maxY = y0 + h; final int maxX = x0 + w; double sigma, dn, i, q; int srcIdx, tgtIdx; final double powFactor = FastMath.pow(referenceSlantRange, 2 * referenceSlantRangeExp); final double sinRefIncidenceAngle = FastMath.sin(referenceIncidenceAngle); final double rescaleCalFactor = rescalingFactor * rescalingFactor * Ks; for (int y = y0; y < maxY; ++y) { srcIndex.calculateStride(y); tgtIndex.calculateStride(y); for (int x = x0; x < maxX; ++x) { srcIdx = srcIndex.getIndex(x); tgtIdx = tgtIndex.getIndex(x); if (bandUnit == Unit.UnitType.AMPLITUDE) { dn = srcData1.getElemDoubleAt(srcIdx); sigma = dn * dn; } else if (bandUnit == Unit.UnitType.INTENSITY) { sigma = srcData1.getElemDoubleAt(srcIdx); } else if (bandUnit == Unit.UnitType.REAL || bandUnit == Unit.UnitType.IMAGINARY) { i = srcData1.getElemDoubleAt(srcIdx); q = srcData2.getElemDoubleAt(srcIdx); sigma = i * i + q * q; } else if (bandUnit == Unit.UnitType.INTENSITY_DB) { sigma = FastMath.pow(10, srcData1.getElemDoubleAt(srcIdx) / 10.0); // convert dB to linear scale } else { throw new OperatorException("CosmoSkymed Calibration: unhandled unit"); } if (applyRangeSpreadingLossCorrection) sigma *= powFactor; if (applyIncidenceAngleCorrection) sigma *= sinRefIncidenceAngle; sigma /= rescaleCalFactor; if (outputImageScaleInDb) { // convert calibration result to dB if (sigma < underFlowFloat) { sigma = -underFlowFloat; } else { sigma = 10.0 * Math.log10(sigma); } } trgData.setElemDoubleAt(tgtIdx, sigma); } } }
From source file:edu.umn.cs.spatialHadoop.nasa.MultiHDFPlot.java
/** * Draws a scale used with the heat map//from w ww. j av a 2 s . co m * @param output * @param valueRange * @param width * @param height * @throws IOException */ private static void drawVerticalScale(Path output, double min, double max, int width, int height, OperationsParams params) throws IOException { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); g.setBackground(Color.BLACK); g.clearRect(0, 0, width, height); // fix this part to work according to color1, color2 and gradient type HDFPlot.HDFRasterizer gradient = new HDFPlot.HDFRasterizer(); gradient.configure(params); HDFRasterLayer gradientLayer = (HDFRasterLayer) gradient.createCanvas(0, 0, new Rectangle()); for (int y = 0; y < height; y++) { Color color = gradientLayer.calculateColor(height - y, 0, height); g.setColor(color); g.drawRect(width * 3 / 4, y, width / 4, 1); } int fontSize = 24; g.setFont(new Font("Arial", Font.BOLD, fontSize)); double step = (max - min) * fontSize * 5 / height; step = (int) (Math.pow(10.0, Math.round(Math.log10(step)))); double min_value = Math.floor(min / step) * step; double max_value = Math.floor(max / step) * step; g.setColor(Color.WHITE); for (double value = min_value; value <= max_value; value += step) { double y = ((value - min) + (max - value) * (height - fontSize)) / (max - min); g.drawString(String.valueOf((int) value), 5, (int) y); } g.dispose(); FileSystem fs = output.getFileSystem(new Configuration()); FSDataOutputStream outStream = fs.create(output, true); ImageIO.write(image, "png", outStream); outStream.close(); }