Example usage for java.lang Math exp

List of usage examples for java.lang Math exp

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static double exp(double a) 

Source Link

Document

Returns Euler's number e raised to the power of a double value.

Usage

From source file:bide.prior.PriorBeta.java

public static double pdf(double x, double alpha, double beta) {
    double z = recomputeZ(alpha, beta);

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

}

From source file:com.QMTunnelling.GaussianPotential.java

public static Double Exp(double x) { //let the Exp function handle a double parameter so we 
    return Math.exp(x); //dont have to worry about which to use
}

From source file:com.davidbracewell.ml.classification.bayes.BernoulliNaiveBayes.java

@Override
protected ClassificationResult classifyImpl(Instance instance) {
    int numClasses = getTargetFeature().alphabetSize();
    double[] probabilities = new double[numClasses];
    double sum = 0d;
    for (int i = 0; i < numClasses; i++) {
        probabilities[i] = FastMath.log10(priors[i]);
        for (int f = 0; f < getFeatures().size(); f++) {
            if (instance.isDefined(f)) {
                probabilities[i] += FastMath.log10(conditionals[f][i]);
            } else {
                probabilities[i] += FastMath.log10(1 - conditionals[f][i]);
            }//w  ww . j  a v  a2  s  . c  om
        }

        probabilities[i] = Math.exp(probabilities[i]);
        sum += probabilities[i];
    }

    //normalize to make probabilities add to one
    for (int i = 0; i < numClasses; i++) {
        probabilities[i] = probabilities[i] / sum;
    }

    return new ClassificationResult(getTargetFeature(), probabilities);
}

From source file:hivemall.utils.math.MathUtils.java

public static double sigmoid(final double x) {
    double x2 = Math.max(Math.min(x, 23.d), -23.d);
    return 1.d / (1.d + Math.exp(-x2));
}

From source file:com.cloudera.hts.utils.math.MyFunc2.java

public double[] gradient(double t, double... parameters) {

    final double a = parameters[0];
    final double b = parameters[1];
    final double c = parameters[2];

    return new double[] { Math.exp(-c * t) * Math.pow(t, b),
            a * Math.exp(-c * t) * Math.pow(t, b) * Math.log(t), a * (-Math.exp(-c * t)) * Math.pow(t, b + 1) };
}

From source file:ch.unil.genescore.vegas.DistributionMethods.java

public static double normalCumulativeProbabilityUpperTailApprox(double q) {

    q = Math.abs(q);/*from  www . ja  va  2 s  . c  om*/
    double aa = -(q * q) / 2 - Math.log(q) - 0.5 * Math.log(2 * Math.PI);
    return (Math.exp(aa));
}

From source file:edu.oregonstate.eecs.mcplan.ml.RadialBasisFunctionKernel.java

@Override
public double apply(final RealVector x, final RealVector y) {
    final RealVector diff = x.subtract(y);
    final double sq_norm2 = diff.dotProduct(diff);
    return Math.exp(gamma_ * sq_norm2);
}

From source file:net.nicoulaj.benchmarks.math.DoubleExp.java

@GenerateMicroBenchmark
public void math(BlackHole hole) {
    for (int i = 0; i < data.length - 1; i++)
        hole.consume(Math.exp(data[i]));
}

From source file:com.opengamma.analytics.financial.model.option.pricing.tree.LogNormalBinomialTreeBuilder.java

@Override
protected double[] getForwards(double[] spots, T data, double t, double dt) {
    int n = spots.length;
    double[] forwards = new double[n];
    for (int i = 0; i < n; i++) {
        double drift = data.getLocalDrift(spots[i], t);
        forwards[i] = spots[i] * Math.exp(drift * dt);
    }// w  w  w .j a v a2 s .  co  m
    return forwards;
}

From source file:edu.byu.nlp.stats.DirichletDistribution.java

private static double[][] moments(double[][] data, int K) {
    double[] expectedX = new double[K];
    double[] expectedXSquared = new double[K];

    for (double[] theta : data) {
        if (theta.length != K) {
            throw new IllegalArgumentException("Dimensions of data and alpha do not match!");
        }// w  w  w  . j  ava2 s.co  m
        for (int k = 0; k < expectedX.length; k++) {
            double p = Math.exp(theta[k]);
            expectedX[k] += p;
            expectedXSquared[k] += p * p;
        }
    }
    DoubleArrays.divideToSelf(expectedX, data.length);
    DoubleArrays.divideToSelf(expectedXSquared, data.length);
    return new double[][] { expectedX, expectedXSquared };
}