List of usage examples for java.lang Math log10
@HotSpotIntrinsicCandidate public static double log10(double a)
From source file:org.broadinstitute.gatk.tools.walkers.variantrecalibration.MultivariateGaussian.java
public void precomputeDenominatorForEvaluation() { precomputeInverse();// w w w . j av a 2 s . c om cachedDenomLog10 = Math.log10(Math.pow(2.0 * Math.PI, -1.0 * ((double) mu.length) / 2.0)) + Math.log10(Math.pow(sigma.det(), -0.5)); }
From source file:org.opensha.sha.magdist.IncrementalMagFreqDist.java
/** * This computes the b-value (the slope of the line of a linear-log plot, meaning * after computing log10 of all y-axis values) between the the given x-axis values. * If Double.NaN is passed in, then the first (or last) non-zero rate is used for * min_bValMag (or max_bValMag)./*from ww w .j a v a 2 s.c o m*/ * @param min_bValMag * @param max_bValMag * @return */ public double compute_bValue(double min_bValMag, double max_bValMag) { int firstIndex, lastIndex; if (Double.isNaN(min_bValMag)) firstIndex = getClosestXIndex(getMinMagWithNonZeroRate()); else firstIndex = getClosestXIndex(min_bValMag); if (Double.isNaN(max_bValMag)) lastIndex = getClosestXIndex(getMaxMagWithNonZeroRate()); else lastIndex = getClosestXIndex(max_bValMag); SimpleRegression regression = new SimpleRegression(); for (int i = firstIndex; i <= lastIndex; i++) { if (getY(i) > 0.0) // avoid taking log of zero regression.addData(getX(i), Math.log10(getY(i))); } // if(getX(lastIndex)-getX(firstIndex) <1.0) // return Double.NaN; return regression.getSlope(); }
From source file:org.broadinstitute.gatk.tools.walkers.cancer.m2.TumorPowerCalculator.java
private double calculateLogLikelihood(final int numReads, final int numAlts, final double alleleFraction) { return ((numReads - numAlts) * Math.log10(alleleFraction * errorProbability + (1 - alleleFraction) * (1 - errorProbability)) + numAlts * Math//from w w w . j a v a2 s. c o m .log10(alleleFraction * (1 - errorProbability) + (1 - alleleFraction) * errorProbability)); }
From source file:org.processmining.analysis.performance.advanceddottedchartanalysis.ui.DottedChartPanel.java
public void adjustSlideBar() { int value = (int) (Math.log10(updWidth / dca.getViewportSize().getWidth()) * 1000.0); if (value > 3000) value = 3000;/*from w w w . j a v a 2 s . c o m*/ dca.getDottedChartOptionPanel().getZoomSliderX().setValue(value); dca.getDottedChartOptionPanel().getZoomSliderX().repaint(); value = (int) (Math.log10(updHight / dca.getViewportSize().getHeight()) * 1000.0); if (value > 3000) value = 3000; dca.getDottedChartOptionPanel().getZoomSliderY().setValue(value); dca.getDottedChartOptionPanel().getZoomSliderY().repaint(); }
From source file:com.glanznig.beepme.data.DataExporter.java
public static String getReadableFileSize(double size, int decimals) { if (size <= 0) { return "0 KB"; }/*from www . j a va2 s. c o m*/ final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" }; int digitGroups = (int) (Math.log10(size) / Math.log10(1024)); NumberFormat numFormat = DecimalFormat.getInstance(); numFormat.setMaximumFractionDigits(decimals); return numFormat.format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups]; }
From source file:org.broadinstitute.gatk.utils.MathUtilsUnitTest.java
@Test public void testLog10Factorial() { logger.warn("Executing testLog10Factorial"); Assert.assertEquals(MathUtils.log10Factorial(4), 1.380211, 1e-6); Assert.assertEquals(MathUtils.log10Factorial(10), 6.559763, 1e-6); Assert.assertEquals(MathUtils.log10Factorial(12), 8.680337, 1e-6); Assert.assertEquals(MathUtils.log10Factorial(200), 374.8969, 1e-3); Assert.assertEquals(MathUtils.log10Factorial(12342), 45138.26, 1e-1); double log10factorial_small = 0; double log10factorial_middle = 374.8969; double log10factorial_large = 45138.26; int small_start = 1; int med_start = 200; int large_start = 12342; for (int i = 1; i < 1000; i++) { log10factorial_small += Math.log10(i + small_start); log10factorial_middle += Math.log10(i + med_start); log10factorial_large += Math.log10(i + large_start); Assert.assertEquals(MathUtils.log10Factorial(small_start + i), log10factorial_small, 1e-6); Assert.assertEquals(MathUtils.log10Factorial(med_start + i), log10factorial_middle, 1e-3); Assert.assertEquals(MathUtils.log10Factorial(large_start + i), log10factorial_large, 1e-1); }// w w w.j av a2 s . com }
From source file:edu.cornell.med.icb.goby.modes.SplitTranscriptsMode.java
/** * Get a number formatter to print leading zeros up to n. * * @param n The largest number that will be formatted * @return the NumberFormat for n/*from w w w . j a v a 2 s . com*/ */ public NumberFormat getNumberFormatter(final int n) { assert n >= 0 : "n must be non-negative"; final int numDigits; if (n == 0) { numDigits = 1; } else { numDigits = 1 + (int) (Math.log10(n)); } final NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setGroupingUsed(false); numberFormat.setMinimumIntegerDigits(numDigits); return numberFormat; }
From source file:hms.hwestra.interactionrebuttal2.InteractionRebuttal2.java
private void determineInteractionPvalueAndMerge(String normal1, String robust1, String out) throws IOException { InteractionRebuttal a = new InteractionRebuttal(); HashMap<String, Double> normalSE = a.loadSE(normal1); HashMap<String, Double> robustSE = a.loadSE(robust1); HashMap<String, Double> normalZ = loadZ(normal1); HashMap<String, Double> robustZ = loadZ(robust1); Set<String> eqtls = normalZ.keySet(); TextFile tf = new TextFile(out, TextFile.W); SpearmansCorrelation corr = new SpearmansCorrelation(); tf.writeln("SNP-Probe\tZNorm\tZRobust\tPNorm\tPRobust\tSENorm\tSERobust"); ArrayList<Double> x = new ArrayList<Double>(); ArrayList<Double> y = new ArrayList<Double>(); ArrayList<Double> x2 = new ArrayList<Double>(); ArrayList<Double> y2 = new ArrayList<Double>(); ArrayList<Double> x3 = new ArrayList<Double>(); ArrayList<Double> y3 = new ArrayList<Double>(); for (String s : eqtls) { if (robustZ.containsKey(s)) { if (!Double.isNaN(normalZ.get(s))) { x.add(normalZ.get(s));/*from w w w . j a v a 2 s. c o m*/ y.add(robustZ.get(s)); x2.add(-Math.log10(ZScores.zToP(normalZ.get(s)))); y2.add(-Math.log10(ZScores.zToP(robustZ.get(s)))); x3.add(normalSE.get(s)); y3.add(robustSE.get(s)); } String ln = s + "\t" + normalZ.get(s) + "\t" + robustZ.get(s) + "\t" + -Math.log10(ZScores.zToP(normalZ.get(s))) + "\t" + -Math.log10(ZScores.zToP(robustZ.get(s))) + "\t" + normalSE.get(s) + "\t" + robustSE.get(s); tf.writeln(ln); } } tf.close(); System.out.println(x.size()); double c = corr.correlation(Primitives.toPrimitiveArr(x.toArray(new Double[0])), Primitives.toPrimitiveArr(y.toArray(new Double[0]))); double c2 = corr.correlation(Primitives.toPrimitiveArr(x2.toArray(new Double[0])), Primitives.toPrimitiveArr(y2.toArray(new Double[0]))); double c3 = Correlation.correlate(Primitives.toPrimitiveArr(x.toArray(new Double[0])), Primitives.toPrimitiveArr(y.toArray(new Double[0]))); double c4 = Correlation.correlate(Primitives.toPrimitiveArr(x2.toArray(new Double[0])), Primitives.toPrimitiveArr(y2.toArray(new Double[0]))); double c5 = corr.correlation(Primitives.toPrimitiveArr(x3.toArray(new Double[0])), Primitives.toPrimitiveArr(y3.toArray(new Double[0]))); double c6 = Correlation.correlate(Primitives.toPrimitiveArr(x3.toArray(new Double[0])), Primitives.toPrimitiveArr(y3.toArray(new Double[0]))); System.out.println("Z Spearman: " + c + " Pearson: " + c3); System.out.println("P Spearman: " + c2 + " Pearson: " + c4); System.out.println("SE Spearman: " + c5 + " Pearson: " + c6); }
From source file:org.moeaframework.util.tree.NodeTest.java
@Test public void testLog10() { Node node = new Log10().setArgument(0, new Constant(5)); Assert.assertTrue(NumberArithmetic.equals(Math.log10(5), (Number) node.evaluate(new UnusedEnvironment()))); }
From source file:com.bmwcarit.barefoot.markov.KStateTest.java
@Test public void TestKStateJSON() throws JSONException { Map<Integer, MockElem> elements = new HashMap<>(); KState<MockElem, StateTransition, Sample> state = new KState<>(1, -1); {//from w w w .ja va 2 s. c o m JSONObject json = state.toJSON(); state = new KState<>(json, new MockFactory()); } 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)); state.update(new HashSet<>(Arrays.asList(elements.get(0), elements.get(1), elements.get(2))), new Sample(0)); { JSONObject json = state.toJSON(); state = new KState<>(json, new MockFactory()); elements.clear(); for (MockElem element : state.vector()) { elements.put(element.numid(), element); } } 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))); state.update( new HashSet<>(Arrays.asList(elements.get(3), elements.get(4), elements.get(5), elements.get(6))), new Sample(1)); { JSONObject json = state.toJSON(); state = new KState<>(json, new MockFactory()); elements.clear(); for (MockElem element : state.vector()) { elements.put(element.numid(), element); } } 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))); state.update( new HashSet<>(Arrays.asList(elements.get(7), elements.get(8), elements.get(9), elements.get(10))), new Sample(2)); { JSONObject json = state.toJSON(); state = new KState<>(json, new MockFactory()); elements.clear(); for (MockElem element : state.vector()) { elements.put(element.numid(), element); } } 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)); state.update( new HashSet<>( Arrays.asList(elements.get(11), elements.get(12), elements.get(13), elements.get(14))), new Sample(3)); state.update(new HashSet<MockElem>(), new Sample(4)); { JSONObject json = state.toJSON(); KState<MockElem, StateTransition, Sample> state2 = new KState<>(json, new MockFactory()); assertEquals(state.size(), state2.size()); assertEquals(5, state2.size()); assertEquals(state.estimate().numid(), state2.estimate().numid()); assertEquals(13, state2.estimate().numid()); assertEquals(state.sequence().size(), state2.sequence().size()); assertEquals(2, state2.sequence().size()); List<Integer> sequence = new LinkedList<>(Arrays.asList(9, 13)); for (int i = 0; i < state.sequence().size() - 1; ++i) { assertEquals(state.sequence().get(i).numid(), state2.sequence().get(i).numid()); assertEquals(sequence.get(i).longValue(), state2.sequence().get(i).numid()); } } }