Example usage for java.lang StrictMath log1p

List of usage examples for java.lang StrictMath log1p

Introduction

In this page you can find the example usage for java.lang StrictMath log1p.

Prototype

public static native double log1p(double x);

Source Link

Document

Returns the natural logarithm of the sum of the argument and 1.

Usage

From source file:Main.java

public static void main(String[] args) {

    double d1 = 90, d2 = 0.0, d3 = (1.0 / 0.0);

    System.out.println("Logarithm value of double (d1 + 1) with base 10 :" + StrictMath.log1p(d1));

    System.out.println("Logarithm value of double (d2 + 1) with base 10 :" + StrictMath.log1p(d2));

    System.out.println("Logarithm value of double (d3 + 1) with base 10 :" + StrictMath.log1p(d3));
}

From source file:edu.cornell.med.icb.goby.stats.TTestCalculator.java

@Override
public DifferentialExpressionInfo evaluate(
        final DifferentialExpressionCalculator differentialExpressionCalculator,
        final NormalizationMethod method, final DifferentialExpressionResults results,
        final DifferentialExpressionInfo info, final String... group) {
    final String groupA = group[0];
    final String groupB = group[1];
    final ObjectArraySet<String> samplesA = differentialExpressionCalculator.getSamples(groupA);
    final ObjectArraySet<String> samplesB = differentialExpressionCalculator.getSamples(groupB);
    if (samplesA.size() < 2 || samplesB.size() < 2) {
        return info;
    }//from  ww  w. ja v  a  2  s .c  om

    final int tTestStatIndex = defineStatisticId(results, "t-test", method, group);
    final int tStatisticStatIndex = defineStatisticId(results, "t-statistic", method, group);

    final double[] valuesA = new double[samplesA.size()];
    final double[] valuesB = new double[samplesB.size()];

    int i = 0;
    for (final String sample : samplesA) {
        valuesA[i++] = StrictMath.log1p(differentialExpressionCalculator.getNormalizedExpressionValue(sample,
                method, info.getElementId()));
    }

    i = 0;
    for (final String sample : samplesB) {
        valuesB[i++] = StrictMath.log1p(differentialExpressionCalculator.getNormalizedExpressionValue(sample,
                method, info.getElementId()));
    }

    double pValue = 0;
    double tStatistic = 0;

    try {
        pValue = mathCommonsTTest.homoscedasticTTest(valuesA, valuesB);
        tStatistic = mathCommonsTTest.t(valuesA, valuesB);
    } catch (MathException e) {
        pValue = Double.NaN;
    }

    info.statistics.size(results.getNumberOfStatistics());
    info.statistics.set(tTestStatIndex, pValue);
    info.statistics.set(tStatisticStatIndex, tStatistic);

    return info;
}

From source file:edu.cornell.med.icb.goby.modes.StatsMode.java

/**
 * Returns the log2 of the sum of the argument plus one.
 *
 * @param x argument./*  ww w . j  a  va  2s .c o m*/
 * @return log2p1(x)=Math.log1p(x)/Math.log(2)
 */
private double log2p1(final double x) {
    return StrictMath.log1p(x) / LOG_2;
}

From source file:edu.umd.honghongie.RunPersonalizedPageRankBasic.java

private static float sumLogProbs(float a, float b) {
    if (a == Float.NEGATIVE_INFINITY)
        return b;

    if (b == Float.NEGATIVE_INFINITY)
        return a;

    if (a < b) {
        return (float) (b + StrictMath.log1p(StrictMath.exp(a - b)));
    }//w  w  w .  j a v a2 s.  c o m
    return (float) (a + StrictMath.log1p(StrictMath.exp(b - a)));
}

From source file:RunPageRankSchimmy.java

private static float sumLogProbs(float a, float b) {
    if (a == Float.NEGATIVE_INFINITY)
        return b;

    if (b == Float.NEGATIVE_INFINITY)
        return a;

    if (a < b) {
        return (float) (b + StrictMath.log1p(StrictMath.exp(a - b)));
    }/*from w  w  w .j  ava  2 s.  co m*/

    return (float) (a + StrictMath.log1p(StrictMath.exp(b - a)));
}

From source file:org.esa.beam.util.math.FastMathPerformance.java

public void testLog1p() {
    System.gc();/*  w  ww  . jav a  2 s. com*/
    double x = 0;
    long time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        x += StrictMath.log1p(Math.PI + i/* 1.0 + i/1e9 */);
    long strictMath = System.nanoTime() - time;

    System.gc();
    double y = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        y += FastMath.log1p(Math.PI + i/* 1.0 + i/1e9 */);
    long fastTime = System.nanoTime() - time;

    System.gc();
    double z = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        z += Math.log1p(Math.PI + i/* 1.0 + i/1e9 */);
    long mathTime = System.nanoTime() - time;

    report("log1p", x + y + z, strictMath, fastTime, mathTime);
}