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:org.broadinstitute.gatk.engine.recalibration.RecalDatumNode.java

/**
 * Calculate the penalty of this interval, given the overall error rate for the interval
 *
 * If the globalErrorRate is e, this value is:
 *
 * sum_i |log10(e_i) - log10(e)| * nObservations_i
 *
 * each the index i applies to all leaves of the tree accessible from this interval
 * (found recursively from subnodes as necessary)
 *
 * @param globalErrorRate overall error rate in real space against which we calculate the penalty
 * @return the cost of approximating the bins in this interval with the globalErrorRate
 *///from w  w  w .jav a2  s  .c o m
@Requires("globalErrorRate >= 0.0")
@Ensures("result >= 0.0")
private double calcPenaltyLog10(final double globalErrorRate) {
    if (globalErrorRate == 0.0) // there were no observations, so there's no penalty
        return 0.0;

    if (isLeaf()) {
        // this is leave node
        return (Math.abs(Math.log10(recalDatum.getEmpiricalErrorRate()) - Math.log10(globalErrorRate)))
                * (double) recalDatum.getNumObservations();
        // TODO -- how we can generalize this calculation?
        //            if ( this.qEnd <= minInterestingQual )
        //                // It's free to merge up quality scores below the smallest interesting one
        //                return 0;
        //            else {
        //                return (Math.abs(Math.log10(getEmpiricalErrorRate()) - Math.log10(globalErrorRate))) * getNumObservations();
        //            }
    } else {
        double sum = 0;
        for (final RecalDatumNode<T> hrd : subnodes)
            sum += hrd.calcPenaltyLog10(globalErrorRate);
        return sum;
    }
}

From source file:com.wildplot.android.ankistats.Forecast.java

public double ticsCalcY(int pixelDistance, Rectangle field, int start, int end) {
    double deltaRange = end - start;
    int ticlimit = field.height / pixelDistance;
    double tics = Math.pow(10, (int) Math.log10(deltaRange / ticlimit));
    while (2.0 * (deltaRange / (tics)) <= ticlimit) {
        tics /= 2.0;/*w  ww  . ja  va  2  s . c  o m*/
    }
    while ((deltaRange / (tics)) / 2 >= ticlimit) {
        tics *= 2.0;
    }
    return tics;
}

From source file:com.microsoft.azure.util.AzureUtil.java

/**
 * Creates a new VM base name given the input parameters.
 * @param templateName Template name/*from w  w  w.  j  a  v a 2s  .  c o  m*/
 * @param osType Type of OS
 * @param numberOfVmsToCreate Number of VMs that will be created
 *       (which is added to the suffix of the VM name by azure)
 * @return 
 */
public static String getVMBaseName(String templateName, String deploymentName, String osType, int numberOfVMs) {
    if (!isValidTemplateName(templateName)) {
        throw new IllegalArgumentException("Invalid template name");
    }

    // For VM names, we use a simpler form.  VM names are pretty short 
    int numberOfDigits = (int) Math.floor(Math.log10((double) numberOfVMs)) + 1;
    // Get the hash of the deployment name
    Integer deploymentHashCode = deploymentName.hashCode();
    // Convert the int into a hex string and do a substring
    String shortenedDeploymentHash = Integer.toHexString(deploymentHashCode).substring(0,
            Constants.VM_NAME_HASH_LENGTH - 1);
    return String.format("%s%s",
            getShortenedTemplateName(templateName, osType, Constants.VM_NAME_HASH_LENGTH, numberOfDigits),
            shortenedDeploymentHash);
}

From source file:org.jax.bham.test.HaplotypeAssociationTestGraphPanel.java

private void cacheChromosomeTests(final int[] chromosomes) {
    List<Integer> chromosomesToCalculate = SequenceUtilities.toIntegerList(chromosomes);
    chromosomesToCalculate.removeAll(this.chromosomeToNegLogValueMap.keySet());

    PerformHaplotypeAssociationTestTask testTask = new PerformHaplotypeAssociationTestTask(this.testToPlot,
            chromosomesToCalculate);//from  ww  w.  j a  va 2s.  co  m
    MultiTaskProgressPanel progressTracker = BhamApplication.getInstance().getBhamFrame()
            .getMultiTaskProgress();
    progressTracker.addTaskToTrack(testTask, true);

    while (testTask.hasMoreElements()) {
        int nextChromosome = testTask.getNextChromosome();
        HaplotypeBlockTestResult[] results = testTask.nextElement();

        List<HaplotypeBlockTestResult> filteredResults = OcclusionFilter
                .filterOutOccludedIntervals(Arrays.asList(results), true);

        RealValuedBasePairInterval[] negLogResults = new RealValuedBasePairInterval[filteredResults.size()];
        for (int i = 0; i < negLogResults.length; i++) {
            negLogResults[i] = new CompositeRealValuedBasePairInterval(
                    filteredResults.get(i).getDelegateInterval(),
                    -Math.log10(filteredResults.get(i).getPValue()));
        }

        this.chromosomeToNegLogValueMap.put(nextChromosome, negLogResults);
    }
}

From source file:dsp.unige.figures.ChannelHelper.java

/**
 * Returns the bit error rate given the information rate
 * //from w  ww . ja v a 2  s.c o  m
 * @param sta the station object
 * @param sat the satellite object
 * @param rate the information rate
 * @return the error probability
 */
public static double getBER(Station sta, Satellite sat, double rate) {
    double SdBW, Eb, N0, EbN0;
    SdBW = getSdBW(sta, sat);
    Eb = 10 * Math.log10(Math.pow(10, SdBW / 10d) / (rate * 1000d));
    N0 = getN0dBW(sta, sat);
    EbN0 = Eb - N0;
    double ber = FEC.getBlockCodePE(EbN0, FEC.getFECParams(sat.FEC).n, FEC.getFECParams(sat.FEC).k,
            FEC.getFECParams(sat.FEC).t);
    if (!Double.isNaN(ber) && ber < 0.5)
        return ber;
    else
        return 0.5;
}

From source file:org.broadinstitute.gatk.utils.MathUtilsUnitTest.java

@Test
public void testLog10BinomialCoefficient() {
    logger.warn("Executing testLog10BinomialCoefficient");
    // note that we can test the binomial coefficient calculation indirectly via Newton's identity
    // (1+z)^m = sum (m choose k)z^k
    double[] z_vals = new double[] { 0.999, 0.9, 0.8, 0.5, 0.2, 0.01, 0.0001 };
    int[] exponent = new int[] { 5, 15, 25, 50, 100 };
    for (double z : z_vals) {
        double logz = Math.log10(z);
        for (int exp : exponent) {
            double expected_log = exp * Math.log10(1 + z);
            double[] newtonArray_log = new double[1 + exp];
            for (int k = 0; k <= exp; k++) {
                newtonArray_log[k] = MathUtils.log10BinomialCoefficient(exp, k) + k * logz;
            }//from  ww w . j  a v a 2  s  .co  m
            Assert.assertEquals(MathUtils.log10sumLog10(newtonArray_log), expected_log, 1e-6);
        }
    }

    Assert.assertEquals(MathUtils.log10BinomialCoefficient(4, 2), 0.7781513, 1e-6);
    Assert.assertEquals(MathUtils.log10BinomialCoefficient(10, 3), 2.079181, 1e-6);
    Assert.assertEquals(MathUtils.log10BinomialCoefficient(103928, 119), 400.2156, 1e-4);
}

From source file:com.wildplot.android.ankistats.AnswerButton.java

public double ticsCalcX(int pixelDistance, Rectangle field) {
    double deltaRange = mMaxElements - 0;
    int ticlimit = field.width / pixelDistance;
    double tics = Math.pow(10, (int) Math.log10(deltaRange / ticlimit));
    while (2.0 * (deltaRange / (tics)) <= ticlimit) {
        tics /= 2.0;//  ww  w.  j av  a 2  s  .c o  m
    }
    while ((deltaRange / (tics)) / 2 >= ticlimit) {
        tics *= 2.0;
    }
    return tics;
}

From source file:org.jax.bham.test.PhylogenyAssociationTestGraphPanel.java

private RealValuedBasePairInterval[] toNegLogResults(List<PhylogenyTestResult> filteredResults) {
    RealValuedBasePairInterval[] negLogResults = new RealValuedBasePairInterval[filteredResults.size()];
    for (int i = 0; i < negLogResults.length; i++) {
        negLogResults[i] = new CompositeRealValuedBasePairInterval(
                filteredResults.get(i).getPhylogenyInterval().getInterval(),
                -Math.log10(filteredResults.get(i).getPValue()));
    }//from   w w  w. j  a va  2s  . co  m

    return negLogResults;
}

From source file:edu.fullerton.viewerplugin.PluginSupport.java

static int getExp(Double miny, Double maxy) {
    int mine = miny == 0 ? 0 : (int) Math.floor(Math.log10(Math.abs(miny)));
    int maxe = maxy == 0 ? 0 : (int) Math.ceil(Math.log10(Math.abs(maxy)));
    int rng = maxe - mine;
    int exp = -(maxe + mine) / 2;

    double min = 0;
    if (miny != 0) {
        min = Math.log10(Math.abs(miny));
    }//from   w  ww  .ja va  2 s .  c om
    double max = 0;
    if (maxy != 0) {
        max = Math.log10(Math.abs(maxy));
    }
    if (Math.abs(max) > Math.abs(min)) {
        exp = -(int) Math.round(max);
    } else {
        exp = -(int) Math.round(min);
    }
    return exp;
}

From source file:org.broadinstitute.gatk.utils.Dirichlet.java

public double[] log10MeanWeights() {
    final double sum = MathUtils.sum(alpha);
    return MathUtils.applyToArray(alpha, x -> Math.log10(x / sum));
}