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:blackscholes.EuropeanCall.java

public double ValuationMethod() {
    NormalDistribution N = new NormalDistribution();
    double _b = r - b;
    double d1 = (Math.log(S / X) + (b + 0.5 * Math.pow(sigma, 2)) * T) / (sigma * Math.sqrt(T));
    double d2 = d1 - sigma * Math.sqrt(T);

    double Nd1 = N.cumulativeProbability(d1);
    double Nd2 = N.cumulativeProbability(d2);
    return S * Nd1 - X * Nd2 * Math.exp((b - r) * T);
}

From source file:bide.prior.PriorBeta.java

public static double logPdf(double x, double alpha, double beta) {

    double z = recomputeZ(alpha, beta);

    double logX = Math.log(x);
    double log1mX = Math.log1p(-x);
    return ((alpha - 1) * logX + (beta - 1) * log1mX - z);
}

From source file:com.opengamma.analytics.math.TrigonometricFunctionUtils.java

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

From source file:Main.java

/**
 * Returns the closest power-of-two number less than or equal to x.
 * //from   w w  w  .j av a  2 s .  com
 * @param x
 * @return the closest power-of-two number less then or equal to x
 */
public static int prevPow2(int x) {
    if (x < 1)
        throw new IllegalArgumentException("x must be greater or equal 1");
    return (int) Math.pow(2, Math.floor(Math.log(x) / Math.log(2)));
}

From source file:brickhouse.udf.bloom.BloomFactory.java

public static Filter NewBloomInstance(int expectedNumberOfElements, double falsePositiveProbability) {
    return NewBloomInstance(Math.ceil(-(Math.log(falsePositiveProbability) / Math.log(2))) / Math.log(2), // c = k / ln(2)
            expectedNumberOfElements, (int) Math.ceil(-(Math.log(falsePositiveProbability) / Math.log(2)))); // k = ceil(-log_2(false prob.))

}

From source file:Main.java

public static int nextExp2(int n) {

    double e = Math.log((double) n) / Math.log(2.0);
    int p = (int) Math.ceil(e);
    double f = n / Math.pow(2.0, (double) p);
    if (f == 0.5) {
        p = p - 1;/* w  ww.j  a v a 2  s  . c o  m*/
    }
    return p;
}

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

/**
 * Returns hartley-Shannon capacity in bps, given Bandwidth (in Hz) and
 * Signal to Noise Ratio.//from   ww w .  j  a  v a2s.  co m
 * 
 * @param B the channel's bandwidth
 * @param s  Signal level in dB
 * @param n  Noise level in dB
 * @return Shannon max. theoretical information rate in bps.
 */
static public double getHSCapacity(int B, double s, double n) {
    System.out.println("ChannelHelper.getHSCapacity() B=" + B + " kHz");
    return B * Math.log(1 + Math.pow(10, (s - n) / 10)) / Math.log(2);
}

From source file:br.unicamp.ic.recod.gpsi.measures.gpsiNormalBhattacharyyaDistanceScore.java

@Override
public double score(double[][][] input) {

    Mean mean = new Mean();
    Variance var = new Variance();

    double mu0, sigs0, mu1, sigs1;
    double dist[][] = new double[2][];

    dist[0] = MatrixUtils.createRealMatrix(input[0]).getColumn(0);
    dist[1] = MatrixUtils.createRealMatrix(input[1]).getColumn(0);

    mu0 = mean.evaluate(dist[0]);// www. ja va2s  .  c  om
    sigs0 = var.evaluate(dist[0]) + Double.MIN_VALUE;
    mu1 = mean.evaluate(dist[1]);
    sigs1 = var.evaluate(dist[1]) + Double.MIN_VALUE;

    double distance = (Math.log((sigs0 / sigs1 + sigs1 / sigs0 + 2) / 4)
            + (Math.pow(mu1 - mu0, 2.0) / (sigs0 + sigs1))) / 4;

    return distance == Double.POSITIVE_INFINITY ? 0 : distance;

}

From source file:com.linkedin.pinot.core.segment.creator.impl.fwd.SingleValueUnsortedForwardIndexCreator.java

public static int getNumOfBits(int dictionarySize) {
    if (dictionarySize < 2) {
        return 1;
    }/* www  .ja v a 2s .co  m*/
    int ret = (int) Math.ceil(Math.log(dictionarySize) / Math.log(2));
    if (ret == 0) {
        ret = 1;
    }
    return ret;
}

From source file:com.opengamma.analytics.financial.interestrate.ContinuousInterestRate.java

@Override
public InterestRate fromPeriodic(final PeriodicInterestRate periodic) {
    Validate.notNull(periodic);/*  ww  w  .java 2 s.  co m*/
    final int m = periodic.getCompoundingPeriodsPerYear();
    return new ContinuousInterestRate(m * Math.log(1 + periodic.getRate() / m));
}