List of usage examples for java.lang Math log10
@HotSpotIntrinsicCandidate public static double log10(double a)
From source file:Main.java
/** Returns a human readable representation of a filesize given in bytes * @author Mr Ed - http://stackoverflow.com/a/5599842 * @param fileSizeInBytes the file size in bytes * @return a human readable representation of the filesize using the following measures: Bytes, KiloBytes, MegaBytes, * GigaBytes, TeraBytes */// w w w .j a va 2 s .c om public static String getReadableFileSize(long fileSizeInBytes) { if (fileSizeInBytes <= 0) { return "0"; } int digitGroups = (int) (Math.log10(fileSizeInBytes) / Math.log10(1024)); return new DecimalFormat("#,##0.#").format(fileSizeInBytes / Math.pow(1024, digitGroups)) + " " + units[digitGroups]; }
From source file:Main.java
/** * Convert a pair of likelihoods into a value suitable for passing to baseAndProbDiffToSqValue. * @param secondBestLikelihood Probability of the 2nd-best base call. 1 > secondBestLikelihood > thirdBestLikelihood. * @param thirdBestLikelihood Probability of the 3rd-best base call. thirdBestLikelihood > 0. * @return ratio of input probabilities for storing in SQ tag. *///from ww w . ja v a2 s . c om public static byte sqScaledProbabilityRatio(final double secondBestLikelihood, final double thirdBestLikelihood) { if (secondBestLikelihood >= 1.0 || thirdBestLikelihood <= 0 || thirdBestLikelihood > secondBestLikelihood) { throw new IllegalArgumentException("Likelihoods out of range. second best: " + secondBestLikelihood + "; third best: " + thirdBestLikelihood); } // Cap value at QUALITY_MASK return (byte) (Math.min(Math.round(-10.0 * Math.log10(thirdBestLikelihood / secondBestLikelihood)), QUALITY_MASK)); }
From source file:com.raghav.plot.XYSeriesDemo.java
/** * A demonstration application showing an XY series containing a null value. * * @param title the frame title.// w w w.ja v a2 s .c om */ public XYSeriesDemo(final String title) { super(title); final XYSeries series = new XYSeries("Random Data"); // float x=1; // float y=(float)((Math.sqrt(2))*x); // for (int i = 1; i < 200000; i++) { double x = (((double) (i)) / 1000); System.out.print("x = " + x); double xdb = 10 * (Math.log10(x)); System.out.print("\t 10logx=" + xdb); double y = Erf.erfc(Math.sqrt(x)); System.out.print("\t y=" + y); System.out.println("----------------------"); series.add(xdb, y); } final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart("XY Series Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:objenome.op.math.Log10.java
@Override public double value(double x) { return Math.log10(x); }
From source file:com.jennifer.ui.util.MathUtil.java
private static double niceNum(double range, boolean round) { double exponent = Math.floor(Math.log10(range)); double fraction = range / Math.pow(10, exponent); double nickFraction; if (round) {/* www. j a va 2 s . c o m*/ if (fraction < 1.5) nickFraction = 1; else if (fraction < 3) nickFraction = 2; else if (fraction < 7) nickFraction = 5; else nickFraction = 10; } else { if (fraction <= 1) nickFraction = 1; else if (fraction <= 2) nickFraction = 2; else if (fraction <= 5) nickFraction = 5; else nickFraction = 10; } return nickFraction * Math.pow(10, exponent); }
From source file:edu.scripps.fl.curves.CurveFit.java
public static void fit(Curve curve) { log.debug("Fitting Curve: " + curve); double y[] = (double[]) ConvertUtils.convert(curve.getResponses(), double[].class); double x[] = (double[]) ConvertUtils.convert(curve.getConcentrations(), double[].class); for (int ii = 0; ii < x.length; ii++) x[ii] = Math.log10(x[ii]); // max, min and range double minY = Double.MAX_VALUE; double maxY = -Double.MAX_VALUE; double maxResp = y[y.length - 1]; for (int i = 0; i < y.length; i++) { minY = Math.min(minY, y[i]); maxY = Math.max(maxY, y[i]); }// w ww.ja v a 2s. c o m curve.setResponseMin(minY); curve.setResponseMax(maxY); curve.setResponseRange(maxY - minY); curve.setMaxResponse(maxResp); // fit boolean flags[] = null; Map maps[] = null; double fitValues[] = null; Object fitResults[] = HillFit.doHill(x, y, null, HillConstants.FIT_ITER_NO, HillConstants.P4_FIT); if (fitResults != null) { flags = (boolean[]) fitResults[0]; fitValues = (double[]) fitResults[1]; maps = (Map[]) fitResults[2]; } if (fitValues != null) { curve.setYZero(fitValues[6]); curve.setLogEC50(fitValues[0]); curve.setYInflection(fitValues[1]); curve.setHillSlope(fitValues[2]); curve.setR2(fitValues[3]); double ec50 = 1000000D * Math.exp(Math.log(10D) * curve.getLogEC50()); double testEC50 = Math.pow(10, curve.getLogEC50()); Double ic50 = null; double logIC50 = BatchHill.iccalc(curve.getYZero(), curve.getYInflection(), curve.getLogEC50(), curve.getHillSlope(), 50D); if (logIC50 < 0.0D) ic50 = 1000000D * Math.exp(Math.log(10D) * logIC50); int dn = Math.max(1, x.length - 4); double df = dn; double p = HillStat.calcPValue(curve.getYZero(), curve.getYInflection(), curve.getLogEC50(), curve.getHillSlope(), x, y, flags); int mask = 0; for (int i = 0; i < x.length; i++) if (!flags[i]) mask++; double ss = HillStat.calcHillDeviation(curve.getLogEC50(), curve.getYZero(), curve.getYInflection(), curve.getHillSlope(), flags, null, x, y); curve.setEC50(ec50); curve.setIC50(ic50); curve.setPHill(p); curve.setSYX(ss / df); for (int ii = 0; ii < flags.length; ii++) { if (flags[ii] == true) { curve.setMasked(true); break; } } } else { curve.setLogEC50(null); curve.setHillSlope(null); curve.setR2(null); curve.setYInflection(null); curve.setYZero(null); curve.setEC50(null); curve.setIC50(null); curve.setPHill(null); curve.setSYX(null); curve.setMasked(false); flags = new boolean[x.length]; } // masks List<Boolean> masks = new ArrayList<Boolean>(flags.length); CollectionUtils.addAll(masks, (Boolean[]) ConvertUtils.convert(flags, Boolean[].class)); curve.setMask(masks); // classify curveClassification(curve, y, x, flags); // rank double rank = -BatchHill.calcRank(curve.getCurveClass(), curve.getMaxResponse(), curve.getResponseRange()); curve.setRank(rank); }
From source file:es.udc.gii.common.eaf.plugin.parameter.LogAnnealing.java
@Override public double get(EvolutionaryAlgorithm algorithm) { return 1.0d - Math.log10(9.0d * counter.getCurrent(algorithm) / counter.getMax(algorithm) + 1.0d); }
From source file:com.antigenomics.mist.umi.UmiErrorAndDiversityModel.java
public double getErrorLogOddsRatio(UmiCoverageAndQuality parent, UmiCoverageAndQuality child) { return Math.log10(errorProbability(parent, child)) - Math.log10(independentAssemblyProbability(parent, child)); }
From source file:org.obiba.genobyte.cli.PrintHistoryCommand.java
public boolean execute(Option opt, CliContext context) throws ParseException { FixedWidthPrinter printer = new FixedWidthPrinter(context.getOutput(), 4); QueryHistory qh = context.getHistory(); int indexWidth = (int) Math.ceil(Math.log10(qh.size() + 1)); int storeNameWidth = Math.max(context.getStore().getAssayRecordStore().getStore().getName().length(), context.getStore().getSampleRecordStore().getStore().getName().length()); int countWidth = Math.max((int) Math.ceil(Math.log10(qh.getMaxCount() + 1)), "Count".length()); printer.setWidths(indexWidth, storeNameWidth, countWidth); // Print header printer.printLine("#", "Store", "Count", "Query"); for (int i = 0; i < qh.size(); i++) { QueryExecution qe = qh.get(i);/*from w w w .jav a 2 s . co m*/ printer.printLine(Integer.toString(i + 1), qe.getStore().getStore().getName(), Integer.toString(qe.count()), qe.getQuery()); } return false; }
From source file:com.algoTrader.util.RoundUtil.java
public static int getDigits(double n) { int exponent = -(int) Math.floor(Math.log10(n)); int digits = exponent >= 0 ? exponent : 0; return digits; }