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:Main.java

public static double sinh(double t) {
    return (Math.exp(t) - Math.exp(-t)) / 2;
}

From source file:com.example.PJS.java

public static double PJSNormal(double x) {
    // returns the cumulative normal distribution function (CNDF)
    // for a standard normal: N(0,1)   
    short adjust;

    if (x < 0) {
        adjust = 1;/*from w  w w . jav a2  s .  c  om*/
        x = -x;
    } else {
        adjust = 0;
    }

    final double t;
    final double poly;
    final double res;

    t = 1 / (1 + 0.2316419 * x);
    poly = ((((1.330274429 * t - 1.821255978) * t + 1.781477937) * t - 0.356563782) * t + 0.31938153) * t;
    res = 1 - 0.398942280401433 * Math.exp(-x * x / 2) * poly;

    if (adjust == 1) {

        return (1 - res);
    } else {
        return (res);
    }
}

From source file:Main.java

/**
 * Returns the <a href="http://mathworld.wolfram.com/HyperbolicSine.html">
 * hyperbolic sine</a> of x./*from  w  w  w  .  ja v  a  2s  .com*/
 * 
 * @param x double value for which to find the hyperbolic sine
 * @return hyperbolic sine of x
 */
public static double sinh(double x) {
    return (Math.exp(x) - Math.exp(-x)) / 2.0;
}

From source file:Main.java

/**
 * Returns the <a href="http://mathworld.wolfram.com/HyperbolicCosine.html">
 * hyperbolic cosine</a> of x.//from w  ww .j av a2  s.c  om
 * 
 * @param x double value for which to find the hyperbolic cosine
 * @return hyperbolic cosine of x
 */
public static double cosh(double x) {
    return (Math.exp(x) + Math.exp(-x)) / 2.0;
}

From source file:gedi.util.math.stat.distributions.LfcDistribution.java

public static double dlfc(double l, double a, double b, boolean log_p) {
    double r = (a * l + 1) * Math.log(2) - MathFunctions.lbeta(a, b) - (a + b) * Math.log(1 + Math.pow(2, l));
    if (!log_p)//from   ww w .j a  v a  2s.  c  o  m
        r = Math.exp(r);
    return r;
}

From source file:com.example.PJS.java

public static double N(double z) {
    /**/*w w w .  j a  va2s  .  com*/
    * Normal Distribution Function, PDF probability density function
    *Odegaard Dic 2003, page 129
    */
    double n = 1 / Math.sqrt(2 * Math.PI) * Math.exp(-0.5 * z * z);
    return n;
}

From source file:etomica.math.SpecialFunctions.java

/**
 * consider using org.apache.commons.math3.special.Erf.erfc()
 * this method is substantially faster (~10x - 100x), but only accurate to ~10^-7
 * //  w  w  w. j a v  a2s.  c o  m
 * Complementary error function, computed using the approximant 7.1.26 of Abramowitz & Stegun.
 * Defined for x >= 0
 */
public static double erfc(double x) {
    double t = 1.0 / (1.0 + 0.3275911 * x);
    return (t * (0.254829592 + t * (-0.284496736 + t * (1.421413741 + t * (-1.453152027 + 1.061405429 * t)))))
            * Math.exp(-x * x);
}

From source file:Util.java

/**
  *  Returns the sum of two doubles expressed in log space,
  *   that is,// ww w. ja va  2 s.  co  m
  * <pre>
  *    sumLogProb = log (e^a + e^b)
 *               = log e^a(1 + e^(b-a))
 *               = a + log (1 + e^(b-a))
  * </pre>
  *
  * By exponentiating <tt>b-a</tt>, we obtain better numerical precision than
  *  we would if we calculated <tt>e^a</tt> or <tt>e^b</tt> directly.
  * <P>
  * Note: This function is just like 
 *  {@link cc.mallet.fst.Transducer#sumNegLogProb sumNegLogProb}
  *   in <TT>Transducer</TT>,
 *   except that the logs aren't negated.
  */
public static double sumLogProb(double a, double b) {
    if (a == Double.NEGATIVE_INFINITY)
        return b;
    else if (b == Double.NEGATIVE_INFINITY)
        return a;
    else if (b < a)
        return a + Math.log(1 + Math.exp(b - a));
    else
        return b + Math.log(1 + Math.exp(a - b));
}

From source file:Main.java

public static double student_c(final double v) {
    return Math.exp(logGamma((v + 1.0) / 2.0))
            / (Math.sqrt(3.141592653589793 * v) * Math.exp(logGamma(v / 2.0)));
}

From source file:com.opengamma.analytics.math.statistics.descriptive.LognormalSkewnessFromVolatilityCalculator.java

@Override
public Double evaluate(final Double sigma, final Double t) {
    Validate.notNull(sigma, "sigma");
    Validate.notNull(t, "t");
    final double y = Math.sqrt(Math.exp(sigma * sigma * t) - 1);
    return y * (3 + y * y);
}