本文整理汇总了Java中org.apache.commons.math3.util.FastMath.exp方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.exp方法的具体用法?Java FastMath.exp怎么用?Java FastMath.exp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.util.FastMath
的用法示例。
在下文中一共展示了FastMath.exp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logDensity
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public double logDensity(double x) {
if (x < 0) {
return Double.NEGATIVE_INFINITY;
}
final double xscale = x / scale;
final double logxscalepow = FastMath.log(xscale) * (shape - 1);
/*
* FastMath.pow(x / scale, shape) =
* FastMath.pow(xscale, shape) =
* FastMath.pow(xscale, shape - 1) * xscale
*/
final double xscalepowshape = FastMath.exp(logxscalepow) * xscale;
return FastMath.log(shape / scale) + logxscalepow - xscalepowshape;
}
示例2: gradient
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
* Computes the value of the gradient at {@code x}.
* The components of the gradient vector are the partial
* derivatives of the function with respect to each of the
* <em>parameters</em>.
*
* @param x Value at which the gradient must be computed.
* @param param Values for {@code k}, {@code m}, {@code b}, {@code q},
* {@code a} and {@code n}.
* @return the gradient vector at {@code x}.
* @throws NullArgumentException if {@code param} is {@code null}.
* @throws DimensionMismatchException if the size of {@code param} is
* not 6.
*/
public double[] gradient(double x, double ... param) {
validateParameters(param);
final double b = param[2];
final double q = param[3];
final double mMinusX = param[1] - x;
final double oneOverN = 1 / param[5];
final double exp = FastMath.exp(b * mMinusX);
final double qExp = q * exp;
final double qExp1 = qExp + 1;
final double factor1 = (param[0] - param[4]) * oneOverN / FastMath.pow(qExp1, oneOverN);
final double factor2 = -factor1 / qExp1;
// Components of the gradient.
final double gk = Logistic.value(mMinusX, 1, b, q, 0, oneOverN);
final double gm = factor2 * b * qExp;
final double gb = factor2 * mMinusX * qExp;
final double gq = factor2 * exp;
final double ga = Logistic.value(mMinusX, 0, b, q, 1, oneOverN);
final double gn = factor1 * Math.log(qExp1) * oneOverN;
return new double[] { gk, gm, gb, gq, ga, gn };
}
示例3: value
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
private Double value() {
if (n > 0) {
return FastMath.exp(value / n);
} else {
return null;
}
}
示例4: getResult
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public double getResult() {
if (sumOfLogs.getN() > 0) {
return FastMath.exp(sumOfLogs.getResult() / sumOfLogs.getN());
} else {
return Double.NaN;
}
}
示例5: cumulativeProbability
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double cumulativeProbability(double x) {
double ret;
if (x <= 0.0) {
ret = 0.0;
} else {
ret = 1.0 - FastMath.exp(-FastMath.pow(x / scale, shape));
}
return ret;
}
示例6: gradient
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
* Computes the value of the gradient at {@code x}.
* The components of the gradient vector are the partial
* derivatives of the function with respect to each of the
* <em>parameters</em>.
*
* @param x Value at which the gradient must be computed.
* @param param Values for {@code k}, {@code m}, {@code b}, {@code q},
* {@code a} and {@code n}.
* @return the gradient vector at {@code x}.
* @throws NullArgumentException if {@code param} is {@code null}.
* @throws DimensionMismatchException if the size of {@code param} is
* not 6.
* @throws NotStrictlyPositiveException if {@code param[5] <= 0}.
*/
public double[] gradient(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException,
NotStrictlyPositiveException {
validateParameters(param);
final double b = param[2];
final double q = param[3];
final double mMinusX = param[1] - x;
final double oneOverN = 1 / param[5];
final double exp = FastMath.exp(b * mMinusX);
final double qExp = q * exp;
final double qExp1 = qExp + 1;
final double factor1 = (param[0] - param[4]) * oneOverN / FastMath.pow(qExp1, oneOverN);
final double factor2 = -factor1 / qExp1;
// Components of the gradient.
final double gk = Logistic.value(mMinusX, 1, b, q, 0, oneOverN);
final double gm = factor2 * b * qExp;
final double gb = factor2 * mMinusX * qExp;
final double gq = factor2 * exp;
final double ga = Logistic.value(mMinusX, 0, b, q, 1, oneOverN);
final double gn = factor1 * FastMath.log(qExp1) * oneOverN;
return new double[] { gk, gm, gb, gq, ga, gn };
}
示例7: hIntegralInverse
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
* The inverse function of H(x).
*
* @param x free parameter
* @return y for which {@code H(y) = x}
*/
private double hIntegralInverse(final double x) {
double t = x*(1d-exponent);
if (t < -1d) {
// Limit value to the range [-1, +inf).
// t could be smaller than -1 in some rare cases due to numerical errors.
t = -1;
}
return FastMath.exp(helper1(t)*x);
}
示例8: probability
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double probability(int x) {
final double logProbability = logProbability(x);
return logProbability == Double.NEGATIVE_INFINITY ? 0 : FastMath.exp(logProbability);
}
示例9: unboundedToBounded
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double unboundedToBounded(final double y) {
return upper - FastMath.exp(-y);
}
示例10: density
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double density(double x) {
return FastMath.exp(-FastMath.abs(x - mu) / beta) / (2.0 * beta);
}
示例11: exp
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public SparseGradient exp() {
final double e = FastMath.exp(value);
return new SparseGradient(e, e, derivatives);
}
示例12: cumulativeProbability
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double cumulativeProbability(double x) {
final double z = (x - mu) / beta;
return FastMath.exp(-FastMath.exp(-z));
}
示例13: density
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double density(double x) {
return FastMath.exp(logDensity(x));
}
示例14: expm1
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public SparseGradient expm1() {
return new SparseGradient(FastMath.expm1(value), FastMath.exp(value), derivatives);
}
示例15: evaluate
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
* Returns the geometric mean of the entries in the specified portion
* of the input array.
* <p>
* See {@link GeometricMean} for details on the computing algorithm.</p>
* <p>
* Throws <code>IllegalArgumentException</code> if the array is null.</p>
*
* @param values input array containing the values
* @param begin first array element to include
* @param length the number of elements to include
* @return the geometric mean or Double.NaN if length = 0 or
* any of the values are <= 0.
* @throws MathIllegalArgumentException if the input array is null or the array
* index parameters are not valid
*/
@Override
public double evaluate(
final double[] values, final int begin, final int length)
throws MathIllegalArgumentException {
return FastMath.exp(
sumOfLogs.evaluate(values, begin, length) / length);
}