Example usage for java.lang Math log10

List of usage examples for java.lang Math log10

Introduction

In this page you can find the example usage for java.lang Math log10.

Prototype

@HotSpotIntrinsicCandidate
public static double log10(double a) 

Source Link

Document

Returns the base 10 logarithm of a double value.

Usage

From source file:com.upstack.materialcamerasample.MainActivity.java

private String readableFileSize(long size) {
    if (size <= 0)
        return size + " B";
    final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" };
    int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
    return new DecimalFormat("#,##0.##").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
}

From source file:hulo.localization.models.obs.GaussianProcessLDPLMeanMulti.java

protected double[] transformFeature(double[] xr, int index_y) {
    int id = activeBeaconList[index_y];
    double[] xs = sourceLocs[id];

    double[] feature = new double[PDIM];
    feature[0] = -10.0 * Math.log10(distance(xr, xs));
    feature[1] = 1;/*from w ww  .  ja  v a  2s. com*/

    double eps = 1e-6;
    feature[2] = floorDiff(xr, xs);
    feature[3] = feature[2] > eps ? 1.0 : 0.0;

    return feature;
}

From source file:libra.core.kmersimilarity_r.KmerSimilarityReducer.java

@Override
protected void reduce(CompressedSequenceWritable key, Iterable<CompressedIntArrayWritable> values,
        Context context) throws IOException, InterruptedException {
    // compute normal
    double[] normal = new double[this.valuesLen];
    for (int i = 0; i < this.valuesLen; i++) {
        normal[i] = 0;//www  .j a v  a 2s. c o m
    }

    for (CompressedIntArrayWritable value : values) {
        int[] arr = value.get();
        int file_id = arr[0];
        int freq = arr[1];
        double tf = 1 + Math.log10(freq);
        normal[file_id] = ((double) tf) / this.tfConsineNormBase[file_id];
    }

    accumulateScore(normal);
}

From source file:net.phyloviz.mstsstatistics.EdgeMST.java

public void setNmsts(int[] map, int[] mapaux, ArrayList[] calcDet, SparseDoubleMatrix2D m, double[] calcnmsts) {
    int u = this.getSource();
    int v = this.getDest();

    int s = map[u];
    int d = map[v];

    if (s == d) {
        _rationmsts = 0;//from ww w .  ja va  2 s  .  c  o  m
        return;
    }

    int[] array = new int[calcDet[mapaux[u]].size() - 2];

    int index = 0;
    Iterator<Integer> it = ((ArrayList<Integer>) calcDet[mapaux[u]]).iterator();

    while (it.hasNext()) {
        int el = it.next();
        if (el != s && el != d) {
            array[index++] = el;
        }
    }

    LUDecomposition tempMax = new LUDecomposition(m.viewSelection(array, array));
    DoubleMatrix2D max = tempMax.getU();
    double det = 0.0;
    if (index != 0) {
        for (int k = 0; k < max.rows(); k++) {
            det += Math.log10(Math.abs(max.get(k, k)));
        }
    }

    if (det == 0.0)
        det = calcnmsts[mapaux[u]];

    _rationmsts = det - calcnmsts[mapaux[u]];

}

From source file:adams.gui.visualization.stats.paintlet.Exponential.java

/**
 * For calculating the dimensions of the plot area.
 */// ww  w  .ja va2  s  .  co  m
@Override
public void calculateDimensions() {
    double median;
    m_Sorted = SpreadSheetUtils.getNumericColumn(m_Data, m_Index);
    m_TransformedY = new double[m_Sorted.length];
    Arrays.sort(m_Sorted);
    for (int i = 0; i < m_Sorted.length; i++) {
        median = ((i + 1) - 0.3) / (m_Sorted.length + 0.4);
        //calculate the transformed y values using inverse exponential
        m_TransformedY[i] = -1 * (Math.log10(1 - median));
    }
    //If the axis can handle the data
    if (m_AxisBottom.getType().canHandle(m_Sorted[0], m_Sorted[m_Sorted.length - 1])) {
        m_AxisBottom.setMinimum(m_Sorted[0]);
        m_AxisBottom.setMaximum(m_Sorted[m_Sorted.length - 1]);
    } else {
        getLogger().severe("errors in plotting");
    }
    if (m_AxisLeft.getType().canHandle(m_TransformedY[0], m_TransformedY[m_TransformedY.length - 1])) {
        m_AxisLeft.setMinimum(m_TransformedY[0]);
        m_AxisLeft.setMaximum(m_TransformedY[m_TransformedY.length - 1]);
    } else {
        getLogger().severe("errors in plotting");
    }
    m_AxisBottom.setAxisName(m_Data.getColumnName(m_Index) + ")");
    m_AxisLeft.setAxisName("Inverse Exponential");
}

From source file:edu.cmu.lti.oaqa.knn4qa.apps.DebugKNNServicImpl.java

static boolean compareApprox(double a, double b, int digits) {
    double maxMod = Math.max(Math.abs(a), Math.abs(b));
    double scale = Math.pow(10, digits);
    double lead = Math.pow(10, Math.round(Math.log10(maxMod)));

    double minSign = Float.MIN_NORMAL * scale;
    // These guys are just too small for us to bother about their differences
    if (maxMod < minSign)
        return true;
    double delta = lead / scale;
    double diff = Math.abs(a - b);
    return diff <= delta;
}

From source file:org.omnaest.utils.codec.EncoderAndDecoderEscaping.java

/**
 * @see EncoderAndDecoderEscaping//  w  ww  .  java2s. c o  m
 * @param escapeCharacter
 * @param encodedCharacters
 */
EncoderAndDecoderEscaping(String escapeCharacter, String[] encodedCharacters) {
    super();

    Assert.isNotNull(escapeCharacter, "escapeCharacter must not be null");
    Assert.isNotNull(encodedCharacters, "encodedCharacters must not be null");
    Assert.isFalse(Pattern.matches(".*[0-9].*", Arrays.deepToString(encodedCharacters)),
            "encodedCharacters must not contain any number");

    final Map<String, String> encodedCharacterToEscapeSequenceMap = new LinkedHashMap<String, String>();
    {
        final String format = "%0" + ((int) Math.ceil(Math.log10(encodedCharacters.length + 1))) + "d";
        int counter = 0;
        for (String encodedCharacter : ArrayUtils.addAll(new String[] { escapeCharacter }, encodedCharacters)) {
            final String escapeSequence = escapeCharacter + String.format(format, counter);
            encodedCharacterToEscapeSequenceMap.put(encodedCharacter, escapeSequence);
            counter++;
        }
    }
    this.encodedCharacterToEscapeSequenceMap = ImmutableMap
            .<String, String>copyOf(encodedCharacterToEscapeSequenceMap);
    this.escapeSequenceToEncodedCharacterMap = ImmutableMap
            .<String, String>copyOf(MapUtils.invertedBidirectionalMap(encodedCharacterToEscapeSequenceMap));
}

From source file:org.gitools.heatmap.decorator.impl.PValueLogSumDecorator.java

private double translateSignificance(double sigLevel) {
    double v = Math.log10(1 - sigLevel) - Math.log10(sigLevel);
    return Math.abs(v);
}

From source file:sanger.team16.gui.genevar.eqtl.snp.RegionalLinePlot.java

private JFreeChart createChart(String chromosome, int position, int distance, double threshold,
        XYDataset dataset) {/*from w  w  w  .ja  v  a  2  s  .  co  m*/
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Position on chromosome " + chromosome + " (bp)",
            "-log10(P)", dataset, PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setShapesVisible(true);
    //renderer.setShapesFilled(false);   //CHANGED 12/12/11
    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    /*       
           XYItemRenderer renderer = plot.getRenderer();  
           int size = dataset.getSeriesCount();
           for (int i=0 ; i<size ; i++) {
    //renderer.setSeriesPaint(i, new Color(255, 0, 0));
    renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3));
    renderer.setBaseSeriesVisibleInLegend(false);
           }
          */
    ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold));
    upperMarker.setPaint(Color.gray);
    float[] f = { 4, 3, 4, 3 };
    upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f));
    plot.addRangeMarker(upperMarker);

    ValueMarker marker = new ValueMarker(0.0);
    marker.setPaint(Color.lightGray);
    plot.addRangeMarker(marker);

    XYSeries series = new XYSeries("Range");
    series.add(position - distance, -0.05);
    series.add(position + distance, -0.05);
    ((XYSeriesCollection) dataset).addSeries(series);
    renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false);

    return chart;
}

From source file:guineu.modules.filter.Alignment.RANSAC.RANSAC.java

/**
 * Calculate k (number of trials)//from  w  w  w .  jav  a 2  s. c o m
 *
 * @return number of trials "k" required to select a subset of n good
 * data points.
 */
private double getK() {
    double w = numRatePoints;
    double b = Math.pow(w, n);
    return Math.log10(1 - 0.99) / Math.log10(1 - b) + (Math.sqrt(1 - b) / b);
}