Example usage for java.lang Math log

List of usage examples for java.lang Math log

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static double log(double a) 

Source Link

Document

Returns the natural logarithm (base e) of a double value.

Usage

From source file:edu.byu.nlp.math.GammaFunctions.java

private static double logRisingFactorialManual(double x, double k) {
    // A few optimized special cases
    if (k == 0) {
        return 0.0;
    }/*from  w w  w  .jav a  2s  . c  o  m*/

    // By starting the accumulator here we can avoid one less compare in the for-loop.
    double acc = Math.log(x);
    if (k == 1) {
        return acc;
    }

    for (int i = 1; i < k; i++) {
        acc += Math.log(x + i);
    }
    return acc;
}

From source file:main.java.utils.Utility.java

public static int getBase(int x) {
    int value = Math.abs(x);

    if (value == 0)
        return 1;
    else/* www  .j a  v  a  2 s  .c  o  m*/
        return (int) (1 + Math.floor((Math.log(value) / Math.log(10.0d))));
}

From source file:peakml.util.jfreechart.LognAxis.java

public LognAxis(String label, int logscale) {
    super(label);
    this.logscale = logscale;
    this.lognvalue = Math.log(logscale);
}

From source file:com.cloudmade.api.Utils.java

/**
 * Convert latitude, longitude pair to tile coordinates
 * /*from   ww  w.j  a v  a2s. c o  m*/
 * @param latitude
 * @param longitude
 * @param zoom
 * @return Tile coordinates [x, y]
 */
public static final int[] latlon2tilenums(double latitude, double longitude, int zoom) {
    int factor = 1 << (zoom - 1);
    latitude = Math.toRadians(latitude);
    longitude = Math.toRadians(longitude);
    double xtile = 1 + longitude / Math.PI;
    double ytile = 1 - Math.log(Math.tan(latitude) + (1 / Math.cos(latitude))) / Math.PI;
    return new int[] { (int) (xtile * factor), (int) (ytile * factor) };
}

From source file:Main.java

/**
 * Returns the closest power-of-two number less than or equal to x.
 *
 * @param x input value/* w ww. jav  a2 s  . c o m*/
 *
 * @return the closest power-of-two number less then or equal to x
 */
public static long prevPow2(long x) {
    if (x < 1) {
        throw new IllegalArgumentException("x must be greater or equal 1");
    }
    return (long) Math.pow(2, Math.floor(Math.log(x) / Math.log(2)));
}

From source file:edu.asu.ca.kaushik.algorithms.permvector.utils.CPHF.java

/**
 * A covering perfect hash family CPHF(n;k,v^t,t).
 * @param n/*from  w w  w.  ja v  a 2s . c  o  m*/
 * @param k
 * @param v
 * @param t
 */
public static int CPHF_LLL(int t, int k, int v) {
    double vTot = Math.pow(v, t);
    double nume = 1.0d;
    for (int i = 1; i < t; i++) {
        nume = nume * (vTot - Math.pow(v, i));
    }

    double dnom = Math.pow(vTot - 1.0d, t - 1);

    double q = 1.0d - nume / dnom;

    double d = CombinatoricsUtils.binomialCoefficientDouble(k, t)
            - CombinatoricsUtils.binomialCoefficientDouble(k - t, t);

    return (int) Math.ceil((1 + Math.log(d)) / (-Math.log(q)));
}

From source file:emlab.util.GeometricTrendRegression.java

public void removeData(double x, double y) {
    super.removeData(x, Math.log(y));
}

From source file:gedi.lfc.foldchange.PosteriorMeanLog2FoldChange.java

@Override
public double computeFoldChange(double a, double b) {
    if (Double.isNaN(a) || Double.isNaN(b))
        return Double.NaN;
    return (Gamma.digamma(a + priorA) - Gamma.digamma(b + priorB)) / Math.log(2);
}

From source file:geogebra.util.MyMath.java

final public static double asinh(double a) {
    return Math.log(a + Math.sqrt(a * a + 1.0));
}

From source file:statistics.distribution.ExponentialDistribution.java

@Override
public long getNextValue() {
    double re = (-1 / lambda) * Math.log(1 - random.nextDouble());
    re += minInterval;/*from w  w  w . j  a  va  2s. c o  m*/
    return (long) (1000 * re);
}