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:br.prof.salesfilho.oci.service.ImageDescriptorService.java

/**
 * @param signal/*w w w .ja v  a2 s.c  o m*/
 * @param kernel Kernel size
 * @return AutoCorrentropy array
 */
public double[] autoCorrentropy(double[] signal, double kernel) {
    //Normalyze
    //signal = OCIUtils.maxElementArrayNormalyze(signal);

    double twokSizeSquare = 2 * Math.pow(kernel, 2d);
    int signal_length = signal.length;
    double[] autoCorrentropy = new double[signal_length];
    double b = 1 / kernel * Math.sqrt(2 * Math.PI);
    int N = signal_length;

    for (int m = 0; m < signal_length; m++) {
        for (int n = m + 1; n < signal_length; n++) {
            double pow = Math.pow((signal[n] - signal[n - m - 1]), 2);
            double exp = Math.exp(-pow / twokSizeSquare);
            double equation = (1d / (N - m + 1d)) * b * exp;
            autoCorrentropy[m] = autoCorrentropy[m] + equation;
        }
    }
    return autoCorrentropy;
}

From source file:org.jfree.chart.demo.XYLogAxesDemo.java

/**
 * Creates a new demo./*www .j a  v a 2 s .  co m*/
 *
 * @param title  the frame title.
 */
public XYLogAxesDemo(final String title) {

    super(title);

    //Object[][][] data = new Object[3][50][2];
    final XYSeries s1 = new XYSeries("Series 1");
    final XYSeries s2 = new XYSeries("Series 2");
    final XYSeries s3 = new XYSeries("Series 3");

    //        for (int i = 1; i <= 50; i++) {
    //            s1.add(i, 1000 * Math.pow(i, -2));
    //            s2.add(i, 1000 * Math.pow(i, -3));
    //            s3.add(i, 1000 * Math.pow(i, -4));
    //        }

    for (int i = 1; i <= 50; i++) {
        s1.add(i, 10 * Math.exp(i / 5.0));
        s2.add(i, 20 * Math.exp(i / 5.0));
        s3.add(i, 30 * Math.exp(i / 5.0));
    }

    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    dataset.addSeries(s3);

    final JFreeChart chart = ChartFactory.createXYLineChart("Log Axis Demo", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, false);

    final XYPlot plot = chart.getXYPlot();
    final NumberAxis domainAxis = new NumberAxis("x");
    final NumberAxis rangeAxis = new LogarithmicAxis("Log(y)");
    plot.setDomainAxis(domainAxis);
    plot.setRangeAxis(rangeAxis);
    chart.setBackgroundPaint(Color.white);
    plot.setOutlinePaint(Color.black);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:com.opengamma.analytics.math.interpolation.LogNaturalCubicMonotonicityPreservingInterpolator1D.java

@Override
public double firstDerivative(final Interpolator1DDataBundle data, final Double value) {
    Validate.notNull(value, "value");
    Validate.notNull(data, "data bundle");
    Validate.isTrue(data instanceof Interpolator1DLogPiecewisePoynomialDataBundle);
    final Interpolator1DLogPiecewisePoynomialDataBundle polyData = (Interpolator1DLogPiecewisePoynomialDataBundle) data;
    final DoubleMatrix1D resValue = FUNC.evaluate(polyData.getPiecewisePolynomialResultsWithSensitivity(),
            value);/* w w  w.j av  a2  s.  c  om*/
    final DoubleMatrix1D resDerivative = FUNC
            .differentiate(polyData.getPiecewisePolynomialResultsWithSensitivity(), value);
    return Math.exp(resValue.getEntry(0)) * resDerivative.getEntry(0);
}

From source file:com.itemanalysis.psychometrics.irt.model.IrmGRM.java

public double cumulativeProbability(double theta, double[] iparam, int category, double D) {
    if (category > maxCategory || category < minCategory)
        return 0;
    if (category == minCategory)
        return 1.0;

    double a = iparam[0];
    double[] s = Arrays.copyOfRange(iparam, 1, iparam.length);

    double Zk = D * a * (theta - s[category - 1]);
    double expZk = Math.exp(Zk);
    double prob = expZk / (1 + expZk);

    return prob;/*from   w  w w.  ja v a2s .co  m*/
}

From source file:edu.snu.leader.spatial.calculator.SigmoidSueurDecisionProbabilityCalculator.java

/**
 * Calculates k coefficient for the collective movement equations
 *
 * @param value// w w w.  j  ava  2 s  .  c  o m
 * @return The k coefficient
 * @see edu.snu.leader.spatial.calculator.AbstractSueurDecisionProbabilityCalculator#calculateK(float)
 */
@Override
protected float calculateK(float value, DecisionType type) {
    return 2.0f * (1.0f / (1.0f + (float) Math.exp((0.5f - value) * _sigmoidSlopeValue)));
}

From source file:geogebra.util.MyMath.java

final public static double beta(double a, double b) {

    return Math.exp(Beta.logBeta(a, b));

}

From source file:com.opengamma.analytics.financial.model.option.pricing.fourier.IntegratedCIRTimeChangeCharacteristicExponent.java

@Override
public ComplexNumber getValue(ComplexNumber u, double t) {
    if (u.getReal() == 0.0 && u.getImaginary() == 0.0) {
        return new ComplexNumber(0.0);
    }/*ww w . j a  v a2  s. c om*/

    final ComplexNumber ui = multiply(I, u);

    //handle small lambda properly 
    if (2 * mod(u) * _lambda * _lambda / _kappa / _kappa < 1e-6) {
        final double d = _theta * t + (1 - _theta) * (1 - Math.exp(-_kappa * t)) / _kappa;
        return multiply(d, ui);
    }

    ComplexNumber temp = subtract(_kappa * _kappa, multiply(2 * _lambda * _lambda, ui));
    final ComplexNumber gamma = sqrt(temp);
    final ComplexNumber gammaHalfT = multiply(gamma, t / 2.0);
    temp = divide(multiply(2, ui), add(_kappa, divide(gamma, TrigonometricFunctionUtils.tanh(gammaHalfT))));
    final ComplexNumber kappaOverGamma = divide(_kappa, gamma);
    final double power = 2 * _kappa * _theta / _lambda / _lambda;
    final ComplexNumber res = add(
            multiply(power, subtract(_kappa * t / 2, getLogCoshSinh(gammaHalfT, kappaOverGamma))), temp);
    return res;
}

From source file:com.opengamma.analytics.math.statistics.distribution.GeneralizedExtremeValueDistribution.java

/**
 * {@inheritDoc}//from  www  .java  2s  .  c om
 * @throws IllegalArgumentException If $x \not\in$ support
 */
@Override
public double getPDF(final Double x) {
    Validate.notNull(x);
    final double t = getT(x);
    return Math.pow(t, _ksi + 1) * Math.exp(-t) / _sigma;
}

From source file:de.mpicbg.knime.hcs.base.utils.MutualInformation.java

public void set_base(Double b) {
    if (!(b == 2 || b == Math.exp(1)))
        System.out.println("The logbase is usually choosen to be 2 or e.");
    if (b < 0)
        throw new RuntimeException("The logbase has to be a positive Real number");
    logbase = b;/*from w ww .j  a  v a  2  s  .c  o  m*/
}

From source file:gedi.util.math.stat.testing.MantelHaenszelTest.java

/**
 * Returns this!//from w  w  w  . j a v a2s  . c o m
 * @param table
 * @return
 * @throws MathException
 */
public MantelHaenszelTest compute(TwoByTwoByKTable table) {
    this.table = table;

    double delta = table.getDelta();
    double yates = correct && (delta >= 0.5) ? 0.5 : 0;
    double deltayates = delta - yates;
    stat = deltayates * deltayates / table.getVarianceEstimate();

    if (h1 == H1.NOT_EQUAL)
        pval = stat > 30 ? 0 : (1 - chisq.cumulativeProbability(stat));
    else if (h1 == H1.LESS_THAN)
        pval = norm.cumulativeProbability(Math.signum(delta) * Math.sqrt(stat));
    else
        pval = 1 - norm.cumulativeProbability(Math.signum(delta) * Math.sqrt(stat));

    estimate = table.getOddsRatio();
    double sd = table.computeSD();

    if (h1 == H1.LESS_THAN) {
        lowerConf = 0;
        upperConf = estimate * Math.exp(norm.inverseCumulativeProbability(confLevel) * sd);
    } else if (h1 == H1.GREATER_THAN) {
        lowerConf = estimate * Math.exp(norm.inverseCumulativeProbability(1 - confLevel) * sd);
        upperConf = Double.POSITIVE_INFINITY;
    } else {
        lowerConf = estimate * Math.exp(norm.inverseCumulativeProbability((1 - confLevel) / 2) * sd);
        upperConf = estimate * Math.exp(-norm.inverseCumulativeProbability((1 - confLevel) / 2) * sd);
    }
    return this;
}