List of usage examples for java.lang Math log10
@HotSpotIntrinsicCandidate public static double log10(double a)
From source file:edu.msu.cme.rdp.alignment.errorcheck.CompareErrorType.java
private Object[] mapQualScores(QSequence seq, String alignedSeqString, boolean reversed) throws IOException { String[] ret = new String[alignedSeqString.length()]; String dealignedSeqString = SeqUtils.getUnalignedSeqString(alignedSeqString); byte[] qualScores = seq.getQuality(); if (qualScores.length != dealignedSeqString.length()) { throw new IOException(seq.getSeqName() + "'s quality string [" + qualScores.length + "] and seq string lengths [" + dealignedSeqString.length() + "] do not match"); }/*from w w w .j a v a 2 s .co m*/ if (reversed) { int start = 0; int end = qualScores.length - 1; while (start < end) { byte tmp = qualScores[start]; qualScores[start] = qualScores[end]; qualScores[end] = tmp; start++; end--; } } float avgEQual = 0; int numQualScores = 0; int scoreIndex = 0; for (int index = 0; index < dealignedSeqString.length(); index++) { while (alignedSeqString.charAt(scoreIndex) == '-') { ret[scoreIndex++] = "-1"; } ret[scoreIndex++] = qualScores[index] + ""; numQualScores++; avgEQual += Math.pow(10, -1 * (Double.valueOf(qualScores[index]) / 10.0)); } avgEQual /= numQualScores; float avgQual = -10 * (float) Math.log10(avgEQual); return new Object[] { ret, avgQual, avgEQual }; }
From source file:org.netxilia.functions.MathFunctions.java
public double LOG10(double number) { return Math.log10(number); }
From source file:org.broadinstitute.gatk.engine.recalibration.RecalDatum.java
/** * Add in all of the data from other into this object, updating the reported quality from the expected * error rate implied by the two reported qualities * * @param other RecalDatum to combine//from w ww. j av a 2s . c o m */ public synchronized void combine(final RecalDatum other) { final double sumErrors = this.calcExpectedErrors() + other.calcExpectedErrors(); increment(other.getNumObservations(), other.getNumMismatches()); estimatedQReported = -10 * Math.log10(sumErrors / getNumObservations()); empiricalQuality = UNINITIALIZED; }
From source file:com.bmwcarit.barefoot.markov.KStateTest.java
@Test public void TestKState() { Map<Integer, MockElem> elements = new HashMap<>(); elements.put(0, new MockElem(0, Math.log10(0.3), 0.3, null)); elements.put(1, new MockElem(1, Math.log10(0.2), 0.2, null)); elements.put(2, new MockElem(2, Math.log10(0.5), 0.5, null)); KState<MockElem, StateTransition, Sample> state = new KState<>(1, -1); {// w ww .j av a 2 s. c om Set<MockElem> vector = new HashSet<>(Arrays.asList(elements.get(0), elements.get(1), elements.get(2))); state.update(vector, new Sample(0)); assertEquals(3, state.size()); assertEquals(2, state.estimate().numid()); } elements.put(3, new MockElem(3, Math.log10(0.3), 0.3, elements.get(1))); elements.put(4, new MockElem(4, Math.log10(0.2), 0.2, elements.get(1))); elements.put(5, new MockElem(5, Math.log10(0.4), 0.4, elements.get(2))); elements.put(6, new MockElem(6, Math.log10(0.1), 0.1, elements.get(2))); { Set<MockElem> vector = new HashSet<>( Arrays.asList(elements.get(3), elements.get(4), elements.get(5), elements.get(6))); state.update(vector, new Sample(1)); assertEquals(6, state.size()); assertEquals(5, state.estimate().numid()); List<Integer> sequence = new LinkedList<>(Arrays.asList(2, 5)); for (int i = 0; i < state.sequence().size() - 1; ++i) { assertEquals(sequence.get(i).longValue(), state.sequence().get(i).numid()); } } elements.put(7, new MockElem(7, Math.log10(0.3), 0.3, elements.get(5))); elements.put(8, new MockElem(8, Math.log10(0.2), 0.2, elements.get(5))); elements.put(9, new MockElem(9, Math.log10(0.4), 0.4, elements.get(6))); elements.put(10, new MockElem(10, Math.log10(0.1), 0.1, elements.get(6))); { Set<MockElem> vector = new HashSet<>( Arrays.asList(elements.get(7), elements.get(8), elements.get(9), elements.get(10))); state.update(vector, new Sample(2)); assertEquals(6, state.size()); assertEquals(9, state.estimate().numid()); List<Integer> sequence = new LinkedList<>(Arrays.asList(6, 9)); for (int i = 0; i < state.sequence().size() - 1; ++i) { assertEquals(sequence.get(i).longValue(), state.sequence().get(i).numid()); } } elements.put(11, new MockElem(11, Math.log10(0.3), 0.3, null)); elements.put(12, new MockElem(12, Math.log10(0.2), 0.2, null)); elements.put(13, new MockElem(13, Math.log10(0.4), 0.4, null)); elements.put(14, new MockElem(14, Math.log10(0.1), 0.1, null)); { Set<MockElem> vector = new HashSet<>( Arrays.asList(elements.get(11), elements.get(12), elements.get(13), elements.get(14))); state.update(vector, new Sample(3)); assertEquals(5, state.size()); assertEquals(13, state.estimate().numid()); List<Integer> sequence = new LinkedList<>(Arrays.asList(9, 13)); for (int i = 0; i < state.sequence().size() - 1; ++i) { assertEquals(sequence.get(i).longValue(), state.sequence().get(i).numid()); } } { Set<MockElem> vector = new HashSet<>(); state.update(vector, new Sample(4)); assertEquals(5, state.size()); assertEquals(13, state.estimate().numid()); List<Integer> sequence = new LinkedList<>(Arrays.asList(9, 13)); for (int i = 0; i < state.sequence().size() - 1; ++i) { assertEquals(sequence.get(i).longValue(), state.sequence().get(i).numid()); } } }
From source file:org.esa.beam.util.math.FastMathTest.java
@Test public void testMathLog10() { for (double i = 0; i < numItr; ++i) { double val = Math.log10(i); }//from www. j a v a 2 s. co m }
From source file:org.archive.nutchwax.scoring.PageRankScoringFilter.java
public float indexerScore(Text key, NutchDocument doc, CrawlDatum dbDatum, CrawlDatum fetchDatum, Parse parse, Inlinks inlinks, float initScore) throws ScoringFilterException { synchronized (this) { if (this.ranks == null) { this.ranks = getPageRanks(this.conf); }//from w ww.j a va 2s . c o m } LOG.info("PageRankScoringFilter: initScore = " + initScore + " ; key = " + key); if (initScore <= 0) { return initScore; } String keyParts[] = key.toString().split("\\s+", 2); if (keyParts.length != 2) { LOG.warn("Unexpected URL/key format: " + key); return initScore; } String url = keyParts[0]; Integer rank = this.ranks.get(url); if (rank == null) { LOG.info("No rank found for: " + url); return initScore; } float newScore = initScore * (float) (Math.log10(rank) + 1); LOG.info("PageRankScoringFilter: initScore = " + newScore + " ; key = " + key); return newScore; }
From source file:com.joptimizer.algebra.MatrixLogSumRescaler.java
/** * Symmetry preserving scale factors//from w w w. j ava 2s . co m * @see Gajulapalli, Lasdon "Scaling Sparse Matrices for Optimization Algorithms", algorithm 3 */ public DoubleMatrix1D getMatrixScalingFactorsSymm(DoubleMatrix2D A) { int n = A.rows(); final double log10_b = Math.log10(base); final int[] x = new int[n]; final double[] cHolder = new double[1]; final double[] tHolder = new double[1]; final int[] currentColumnIndexHolder = new int[] { -1 }; IntIntDoubleFunction myFunct = new IntIntDoubleFunction() { public double apply(int i, int j, double pij) { int currentColumnIndex = currentColumnIndexHolder[0]; // we take into account only the lower left subdiagonal part of Q (that is symmetric) if (i == currentColumnIndex) { //diagonal element //log.debug("i:" + i + ", j:" + currentColumnIndex + ": " + pij); tHolder[0] = tHolder[0] - 0.5 * (Math.log10(Math.abs(pij)) / log10_b + 0.5);//log(b, x) = log(k, x) / log(k, b) cHolder[0] = cHolder[0] + 1; } else if (i > currentColumnIndex) { //sub-diagonal elements //log.debug("i:" + i + ", j:" + currentColumnIndex + ": " + pij); tHolder[0] = tHolder[0] - 2 * (Math.log10(Math.abs(pij)) / log10_b + 0.5) - 2 * x[i];//log(b, x) = log(k, x) / log(k, b) cHolder[0] = cHolder[0] + 2;//- 2*x[i] } return pij; } }; //view A column by column for (int currentColumnIndex = n - 1; currentColumnIndex >= 0; currentColumnIndex--) { //log.debug("currentColumnIndex:" + currentColumnIndex); cHolder[0] = 0;//reset tHolder[0] = 0;//reset currentColumnIndexHolder[0] = currentColumnIndex; DoubleMatrix2D P = A.viewPart(0, currentColumnIndex, n, 1); P.forEachNonZero(myFunct); if (cHolder[0] > 0) { x[currentColumnIndex] = (int) Math.round(tHolder[0] / cHolder[0]); } } //log.debug("x: " + ArrayUtils.toString(x)); DoubleMatrix1D u = new DenseDoubleMatrix1D(n); for (int k = 0; k < n; k++) { u.setQuick(k, Math.pow(base, x[k])); } return u; }
From source file:com.musicg.api.DetectionApi.java
protected void normalizeSpectrogramData(double[][] spectrogramData) { // normalization of absoultSpectrogram // set max and min amplitudes double maxAmp = Double.MIN_VALUE; double minAmp = Double.MAX_VALUE; for (int i = 0; i < spectrogramData.length; i++) { for (int j = 0; j < spectrogramData[i].length; j++) { if (spectrogramData[i][j] > maxAmp) { maxAmp = spectrogramData[i][j]; } else if (spectrogramData[i][j] < minAmp) { minAmp = spectrogramData[i][j]; }/*ww w . j a v a 2s.c o m*/ } } // end set max and min amplitudes // normalization // avoiding divided by zero double minValidAmp = 0.00000000001F; if (minAmp == 0) { minAmp = minValidAmp; } double diff = Math.log10(maxAmp / minAmp); // perceptual difference for (int i = 0; i < spectrogramData.length; i++) { for (int j = 0; j < spectrogramData[i].length; j++) { if (spectrogramData[i][j] < minValidAmp) { spectrogramData[i][j] = 0; } else { spectrogramData[i][j] = (Math.log10(spectrogramData[i][j] / minAmp)) / diff; } } } // end normalization }
From source file:org.h819.commons.file.MyFileUtils.java
/** * ??// w w w . j av a 2 s. com * * @param fileSize * @return */ public static String getHumanReadableSize(long fileSize) { String[] units = new String[] { "B", "KB", "MB", "GB", "TB" }; int unitIndex = (int) (Math.log10(fileSize) / 3); double unitValue = 1 << (unitIndex * 10); return new DecimalFormat("#,##0.#").format(fileSize / unitValue) + " " + units[unitIndex]; }
From source file:adapters.XYChartAdapter.java
private double[] adjustRangeBounds(double bmin, double bmax) { // resets chart lower and upper bounds to round values. // Returns corrected [lowerBound, upperBound] double del = (bmax - bmin) / 20.0; // Choose 20 intervals to round int a = (int) Math.floor(0.5 + Math.log10(del)); double d = Math.pow(10.0, (double) a); // power of 10 double lower = d * Math.ceil((bmin - del) / d); if (lower > bmin) lower -= d;//from www . ja va2 s . c o m if (0 == Math.abs(bmin)) lower = 0; double upper = d * Math.floor((bmax + del) / d); if (upper < bmax) upper += d; double[] range = new double[2]; range[0] = lower; range[1] = upper; return range; }