/** {@inheritDoc} */ public double probability(int x) { if (x < 0) { return 0.0; } else { return FastMath.exp(log1mProbabilityOfSuccess * x) * probabilityOfSuccess; } }
/** * {@inheritDoc} * * For scale {@code m} and shape {@code s}, the variance is * {@code (exp(s^2) - 1) * exp(2 * m + s^2)}. */ public double getNumericalVariance() { final double s = shape; final double ss = s * s; return (FastMath.expm1(ss)) * FastMath.exp(2 * scale + ss); }
/** * {@inheritDoc} * * For scale {@code m} and shape {@code s}, the mean is * {@code exp(m + s^2 / 2)}. */ public double getNumericalMean() { double s = shape; return FastMath.exp(scale + (s * s / 2)); }
/** * Computes <code>a e<sup>-numCall / b</sup></code>. * * @param numCall Current step of the training task. * @return the value of the function at {@code numCall}. */ public double value(long numCall) { return a * FastMath.exp(-numCall * oneOverB); } }
/** * @param x Value at which to compute the sigmoid. * @param lo Lower asymptote. * @param hi Higher asymptote. * @return the value of the sigmoid function at {@code x}. */ private static double value(double x, double lo, double hi) { return lo + (hi - lo) / (1 + FastMath.exp(-x)); }
/** * {@inheritDoc} */ public double density(double x) { if (means != null) throw new IllegalStateException("Unable to sample from more than one mean"); final double x0 = x - mean; final double x1 = x0 / standardDeviation; return FastMath.exp(-0.5 * x1 * x1) / (standardDeviation * SQRT2PI); }
/** * {@inheritDoc} */ public double density(double x) { if (means != null) throw new IllegalStateException("Unable to sample from more than one mean"); final double x0 = x - mean; final double x1 = x0 / standardDeviation; return FastMath.exp(-0.5 * x1 * x1) / (standardDeviation * SQRT2PI); }
/** * {@inheritDoc} */ public double density(double x) { if (means != null) throw new IllegalStateException("Unable to sample from more than one mean"); final double x0 = x - mean; final double x1 = x0 / standardDeviation; return FastMath.exp(-0.5 * x1 * x1) / (standardDeviation * SQRT2PI); }
/** {@inheritDoc} * @since 3.2 */ public Decimal64 exp() { return new Decimal64(FastMath.exp(value)); }
/** {@inheritDoc} */ public double probability(int x) { final double logProbability = logProbability(x); return logProbability == Double.NEGATIVE_INFINITY ? 0 : FastMath.exp(logProbability); }
/** * {@inheritDoc} * * @since 2.1 */ public double density(double x) { return FastMath.exp(logDensity(x)); }
/** {@inheritDoc} */ @Override public double sample() { final double n = random.nextGaussian(); return FastMath.exp(scale + shape * n); } }
/** {@inheritDoc} */ public double density(double x) { final double logDensity = logDensity(x); return logDensity == Double.NEGATIVE_INFINITY ? 0 : FastMath.exp(logDensity); }
public Builder removeSegment(DataSegment dataSegment) { SegmentAndSum segmentAndSum = new SegmentAndSum(dataSegment, 0.0, 0.0); if (!segments.remove(segmentAndSum)) { return this; } double t0 = convertStart(dataSegment, interval); double t1 = convertEnd(dataSegment, interval); double leftValue = FastMath.exp(t0) - FastMath.exp(t1); double rightValue = FastMath.exp(-t1) - FastMath.exp(-t0); segments.tailSet(segmentAndSum).forEach(v -> v.leftSum -= leftValue); segments.headSet(segmentAndSum).forEach(v -> v.rightSum -= rightValue); return this; }
private double rightCost(DataSegment dataSegment, double t0, double t1, int index) { double rightCost = 0.0; // add all right-overlapping segments int rightIndex = index; while (rightIndex < sortedSegments.size() && sortedSegments.get(rightIndex).getInterval().overlaps(dataSegment.getInterval())) { double start = convertStart(sortedSegments.get(rightIndex), interval); double end = convertEnd(sortedSegments.get(rightIndex), interval); rightCost += CostBalancerStrategy.intervalCost(t1 - t0, start - t0, end - t0); ++rightIndex; } // add right-non-overlapping segments if (rightIndex < sortedSegments.size()) { rightCost += rightSum[rightIndex] * (FastMath.exp(t0) - FastMath.exp(t1)); } return rightCost; }
private double addLeftCost(DataSegment dataSegment, double t0, double t1, int index) { double leftCost = 0.0; // add to cost all left-overlapping segments int leftIndex = index - 1; while (leftIndex >= 0 && sortedSegments.get(leftIndex).getInterval().overlaps(dataSegment.getInterval())) { double start = convertStart(sortedSegments.get(leftIndex), interval); double end = convertEnd(sortedSegments.get(leftIndex), interval); leftCost += CostBalancerStrategy.intervalCost(end - start, t0 - start, t1 - start); --leftIndex; } // add left-non-overlapping segments if (leftIndex >= 0) { leftCost += leftSum[leftIndex] * (FastMath.exp(-t1) - FastMath.exp(-t0)); } return leftCost; }
/** * {@inheritDoc} */ @Override public double getResult() { if (sumOfLogs.getN() > 0) { return FastMath.exp(sumOfLogs.getResult() / sumOfLogs.getN()); } else { return Double.NaN; } }
/** * used by {@link #getNumericalVariance()} * * @return the variance of this distribution */ protected double calculateNumericalVariance() { final double sh = getShape(); final double sc = getScale(); final double mn = getNumericalMean(); return (sc * sc) * FastMath.exp(Gamma.logGamma(1 + (2 / sh))) - (mn * mn); }
/** {@inheritDoc} */ public double density(double x) { if (x <= 0) { return 0.0; } return 2.0 * FastMath.pow(mu, mu) / (Gamma.gamma(mu) * FastMath.pow(omega, mu)) * FastMath.pow(x, 2 * mu - 1) * FastMath.exp(-mu * x * x / omega); }
@Override public IComplexNumber exp() { IComplexNumber result = dup(); double realExp = FastMath.exp(realComponent()); return result.set(realExp * FastMath.cos(imaginaryComponent()), realExp * FastMath.sin(imaginaryComponent())); }