List of usage examples for org.apache.commons.math3.util FastMath exp
public static double exp(double x)
From source file:com.vsthost.rnd.commons.math.ext.linear.ExtMath.java
/** * Returns a fast, nearly accurate implementation of exponential function. * * <p>Note that the implementation is not yet settled. There are faster or more accurate ways to do it.</p> * * @param x A double value to be provided * @return The e^x as a double value.//from w w w .j a v a2 s . c o m */ public static double fastExp(double x) { return FastMath.exp(x); // Below, we have other ways of achieving this: // // Method 1: // ========= // x = 1d + x / 256d; // x *= x; x *= x; x *= x; x *= x; // x *= x; x *= x; x *= x; x *= x; // return x; // // Method 2: // ========= // // return Math.exp(x); // // Method 3: // ========= // // return Double.longBitsToDouble(((long) (1512775 * val + 1072632447)) << 32); // // Method 4: // ========= // // return Double.longBitsToDouble(((long) (1512775 * val + (1072693248 - 60801))) << 32); }
From source file:edu.emory.mathcs.nlp.learning.util.MLUtils.java
/** Transform the scores into softmax regression. */ static public void softmax(float[] scores) { float sum = 0; for (int i = 0; i < scores.length; i++) { scores[i] = (float) FastMath.exp(scores[i]); sum += scores[i];//from w w w. j a v a 2s . com } for (int i = 0; i < scores.length; i++) scores[i] /= sum; }
From source file:jmb.jcortex.mapfunctions.SigmoidActivationFunction.java
@Override public DoubleUnaryOperator getFunction() { return x -> 1 / (1 + FastMath.exp(-x)); }
From source file:gdsc.smlm.model.AiryPattern.java
/** * Calculate the intensity of the AiryPattern at distance x from the centre using a Gaussian approximation * /*ww w .j av a 2s . c o m*/ * @param x * @return The intensity */ public static double intensityGaussian(double x) { if (x == 0) return 1; x /= FACTOR; return FastMath.exp(-0.5 * (x * x)); }
From source file:com.gedaeusp.domain.Exponential.java
public static double value(double t, double v0, double a, double tau) { return v0 + a * FastMath.exp(-t / tau); }
From source file:edu.emory.mathcs.nlp.deeplearning.activation.SoftmaxFunction.java
@Override public void transform(double[] scores) { double sum = 0; for (int i = 0; i < scores.length; i++) { scores[i] = FastMath.exp(scores[i]); sum += scores[i];// w ww .java 2s .c om } for (int i = 0; i < scores.length; i++) scores[i] /= sum; }
From source file:com.gedaeusp.domain.Biexponential.java
public static double value(double t, double v0, double a1, double a2, double tau1, double tau2) { return v0 + a1 * FastMath.exp(-t / tau1) + a2 * FastMath.exp(-t / tau2); }
From source file:edu.emory.mathcs.nlp.learning.activation.SoftmaxFunction.java
@Override public void apply(float[] scores) { float sum = 0, max = DSUtils.max(scores); max = 0;//from www. j a va2s .com for (int i = 0; i < scores.length; i++) { scores[i] = (float) FastMath.exp(scores[i] - max); sum += scores[i]; } sum = 1f / (1 + sum); for (int i = 0; i < scores.length; i++) scores[i] *= sum; }
From source file:com.davidbracewell.math.functions.LogLoss.java
@Override public double calculate(double n1, double n2) { return FastMath.log(1 + FastMath.exp(-(n1 * n2))); }
From source file:edu.emory.mathcs.nlp.learning.normalization.SoftmaxFunction.java
@Override public void apply(float[] scores) { float sum = 0, max = DSUtils.max(scores); max = 0;//from ww w.j ava 2 s.co m for (int i = 0; i < scores.length; i++) { scores[i] = (float) FastMath.exp(scores[i] - max); sum += scores[i]; } if (sum != 0) { sum = 1f / sum; } for (int i = 0; i < scores.length; i++) scores[i] *= sum; }