Example usage for java.lang Double POSITIVE_INFINITY

List of usage examples for java.lang Double POSITIVE_INFINITY

Introduction

In this page you can find the example usage for java.lang Double POSITIVE_INFINITY.

Prototype

double POSITIVE_INFINITY

To view the source code for java.lang Double POSITIVE_INFINITY.

Click Source Link

Document

A constant holding the positive infinity of type double .

Usage

From source file:com.analog.lyric.dimple.factorfunctions.ExchangeableDirichlet.java

@Override
public final double evalEnergy(Value[] arguments) {
    int index = 0;
    if (!_parametersConstant) {
        _alpha = arguments[index++].getDouble(); // First variable is parameter value
        if (_alpha <= 0)
            return Double.POSITIVE_INFINITY;
        _logBetaAlpha = logBeta(_alpha);
    }//from   www.ja  v a2  s.  com

    double sum = 0;
    final int length = arguments.length;
    final int N = length - index; // Number of non-parameter variables
    for (; index < length; index++) {
        final double[] x = arguments[index].getDoubleArray(); // Remaining inputs are Dirichlet distributed random variable vectors
        if (x.length != _dimension)
            throw new DimpleException(
                    "Dimension of variable does not equal to the dimension of the parameter vector.");
        double xSum = 0;
        for (int i = 0; i < _dimension; i++) {
            final double xi = x[i];
            if (xi <= 0)
                return Double.POSITIVE_INFINITY;
            else
                sum -= Math.log(xi); // -log(x_i ^ (a_i-1))
            xSum += xi;
        }

        if (!almostEqual(xSum, 1, SIMPLEX_THRESHOLD * _dimension)) // Values must be on the probability simplex
            return Double.POSITIVE_INFINITY;
    }

    return sum * (_alpha - 1) + N * _logBetaAlpha;
}

From source file:dr.inference.distribution.GammaDistributionModel.java

/**
 * Construct a gamma distribution model.
 *///ww w  .j ava2  s  . c o m
public GammaDistributionModel(GammaParameterizationType parameterization, Variable<Double> shape,
        Variable<Double> parameter2, double offset) {

    super(GAMMA_DISTRIBUTION_MODEL);

    this.offset = offset;

    this.parameterization = parameterization;
    this.shape = shape;
    addVariable(shape);
    shape.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));

    switch (parameterization) {
    case ShapeScale:
        this.scale = parameter2;
        addVariable(scale);
        scale.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
        rate = null;
        mean = null;
        break;
    case ShapeRate:
        this.rate = parameter2;
        addVariable(rate);
        rate.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
        scale = null;
        mean = null;
        break;
    case ShapeMean:
        this.mean = parameter2;
        addVariable(mean);
        mean.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
        scale = null;
        rate = null;
        break;
    case OneParameter:
        scale = null;
        rate = null;
        mean = null;
        break;
    default:
        throw new IllegalArgumentException("Unknown parameterization type");
    }
}

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

/**
 * 
 * @return $\infty$
 */
@Override
public double getLargestAlpha() {
    return Double.POSITIVE_INFINITY;
}

From source file:com.vsthost.rnd.jdeoptim.evolution.Population.java

/**
 * Instantiates a population by generating a random population with the arguments provided.
 *
 * @param size The size of the population.
 * @param dimension The dimension of a population member.
 * @param lowerLimits Lower limits for the population.
 * @param upperLimits Upper limits for the population.
 * @param distribution The real-value distribution to be used.
 */// ww w. j  av  a 2 s  . c  om
public Population(int size, int dimension, double[] lowerLimits, double[] upperLimits,
        RealDistribution distribution) {
    // Generate a random population and save it:
    this.data = Utils.randomPopulation(size, dimension, lowerLimits, upperLimits, distribution);

    // Save the size and dimension fields:
    this.size = size;
    this.dimension = dimension;

    // Initialize the scores:
    this.setScores(Double.POSITIVE_INFINITY);
}

From source file:mase.app.foraging.FlyingRobot.java

public FlyingRobot(ForagingTask sim, Continuous2D field, AgentController ac) {
    super(sim, field, sim.par.flyingRadius, COLOR, ac);

    if (sim.par.flyingStartHeight < 5) {
        this.setCollidableTypes(EmboddiedAgent.class);
    }/* ww w. jav a2 s  . com*/
    this.enableBoundedArena(false);

    effector = new FlyingEffector(sim, field, this);
    super.addEffector(effector);
    effector.enableAltitude(sim.par.flyingVerticalMovement);
    effector.setHeight(sim.par.flyingStartHeight);
    effector.setMaxHeight(sim.par.flyingMaxHeight);
    effector.setAccelerationLimits(sim.par.flyingLinearAcc, sim.par.flyingAngAcc);
    effector.calculateDragCoefficients(sim.par.flyingLinearSpeed, sim.par.flyingAngSpeed);
    effector.setNoise(sim.par.actuatorNoise);

    double vRange = sim.par.flyingStartHeight * FastMath.tan(sim.par.flyingVisionAngle / 2);

    itemArcs = new DistanceSensorArcs(sim, field, this);
    super.addSensor(itemArcs);
    itemArcs.centerToCenter(true);
    itemArcs.setRange(vRange);
    itemArcs.setArcs(sim.par.flyingArcs);
    itemArcs.setBinary(false);
    itemArcs.setObjectTypes(Item.class);
    itemArcs.setNoise(sim.par.sensorRangeNoise, sim.par.sensorAngleNoise, DistanceSensorArcs.UNIFORM);

    botArcs = new DistanceSensorArcs(sim, field, this);
    super.addSensor(botArcs);
    botArcs.centerToCenter(true);
    botArcs.setRange(vRange);
    botArcs.setArcs(sim.par.flyingArcs);
    botArcs.setBinary(false);
    botArcs.setObjectTypes(LandRobot.class);
    botArcs.setNoise(sim.par.sensorRangeNoise, sim.par.sensorAngleNoise, DistanceSensorArcs.UNIFORM);

    if (sim.par.flyingVerticalMovement) {
        HeightSensor hs = new HeightSensor(sim, field, this);
        hs.setFlyingEffector(effector);
        hs.setNoise(sim.par.sensorRangeNoise);
        super.addSensor(hs);
        effector.updateHeight();
    }

    centre = new RangeBearingSensor(sim, field, this);
    centre.setObjects(Collections.singletonList(
            new PointObject(field, new Double2D(sim.par.arenaSize.x / 2, sim.par.arenaSize.y / 2))));
    centre.setRange(Double.POSITIVE_INFINITY);
    centre.setNoise(sim.par.sensorRangeNoise, sim.par.sensorAngleNoise, DistanceSensorArcs.UNIFORM);
    super.addSensor(centre);
}

From source file:com.github.rinde.rinsim.util.StochasticSuppliersTest.java

/**
 * Tests for/*from   w  w w.j av a 2 s. c om*/
 * {@link StochasticSuppliers#checked(StochasticSupplier, Predicate)}.
 */
@Test
public void testCheckedSupplier() {
    final Predicate<Double> positive = Range.closedOpen(0d, Double.POSITIVE_INFINITY);

    checked(constant(0d), positive).get(0);
    checked(constant(453453453.34), positive).get(0);
    checked(constant(Double.MAX_VALUE), positive).get(0);

    boolean fail = false;
    try {
        checked(constant(Double.POSITIVE_INFINITY), positive).get(0);
    } catch (final IllegalArgumentException e) {
        fail = true;
    }
    assertTrue(fail);
    fail = false;
    try {
        checked(constant(-0.0000000001), positive).get(0);
    } catch (final IllegalArgumentException e) {
        fail = true;
    }
    assertTrue(fail);
}

From source file:ffx.algorithms.Stochastic.java

/**
 * Constructor for Stochastic Dynamics.//from  w  ww  . j ava 2 s  .c  om
 *
 * @param friction Friction coefficient.
 * @param nVariables Number of variables.
 * @param x Variables current value.
 * @param v Current velocities.
 * @param a Current accelerations.
 * @param mass Mass of the variables.
 */
public Stochastic(double friction, int nVariables, double x[], double v[], double a[], double mass[]) {
    super(nVariables, x, v, a, mass);
    this.friction = friction;
    if (friction >= 0) {
        inverseFriction = 1.0 / friction;
    } else {
        inverseFriction = Double.POSITIVE_INFINITY;
    }
    vfric = new double[nVariables];
    vrand = new double[nVariables];
    fdt = friction * dt;
    efdt = exp(-fdt);
    temperature = 298.15;
    random = new Random();
}

From source file:com.facebook.presto.operator.aggregation.ApproximateUtils.java

/**
 * Computes the standard deviation for the random variable S = sum(1 / p * X * Bern(p))
 * <br /><br />/*from www .j  a  v  a2  s .c  o m*/
 * Derivation:
 * <pre>
 * Var(S) = Var(sum(1 / p * X * Bern(p)))
 *        = sum(Var(1 / p * X * Bern(p)))                                                           [Bienayme formula]
 *        = n * Var(1 / p * X * Bern(p))                                                            [X * Bern(p) are iid]
 *        = n * 1 / p^2 * Var(X * Bern(p))                                                          [1 / p is constant]
 *        = n * 1 / p^2 * (Var(X) * Var(Bern(p)) + E(X)^2 * Var(Bern(p)) + Var(X) * E(Bern(p))^2    [Product of independent variables]
 *        = n * 1 / p^2 * (Var(X) * p(1 - p) + E(X)^2 * p(1 - p) + Var(X) * p^2)                    [Variance of a Bernoulli distribution]
 *        = n * 1 / p * (Var(X) + E(X)^2 * (1 - p))
 *        = samples / p^2 * (Var(X) + E(X)^2 * (1 - p))                                             [samples = n * p, since it's only the observed rows]
 * </pre>
 * Therefore Stddev(S) = 1 / p * sqrt(samples * (variance + mean^2 * (1 - p)))
 */
public static double sumError(long samples, long count, double m2, double mean) {
    if (count == 0) {
        return Double.POSITIVE_INFINITY;
    }

    double p = samples / (double) count;
    double variance = m2 / samples;
    double error = 1 / p * Math.sqrt(samples * (variance + mean * mean * (1 - p)));
    return conservativeError(error, p, samples);
}

From source file:com.analog.lyric.dimple.factorfunctions.Multinomial.java

@Override
public final double evalEnergy(Value[] arguments) {
    int index = 0;
    if (!_NParameterConstant) {
        _N = arguments[index++].getInt(); // First argument is N parameter
        if (_N < 0)
            return Double.POSITIVE_INFINITY;
        _negativeLogFactorialN = -org.apache.commons.math3.special.Gamma.logGamma(_N + 1);
    }//from   w w  w . ja  v  a  2 s .  c om

    final double[] alpha = arguments[index++].getDoubleArray(); // Next argument is the probability parameter vector
    final int dimension = alpha.length;

    if (arguments.length - index != dimension)
        throw new DimpleException(
                "Number of count variables must equal the dimension of the parameter vector.");

    int countSum = 0;
    double parameterSum = 0;
    double sum = _negativeLogFactorialN;
    for (int i = 0; i < dimension; i++) {
        final double alphai = alpha[i];
        if (alphai < 0)
            return Double.POSITIVE_INFINITY;
        parameterSum += alphai;

        final int x = arguments[index++].getInt(); // Remaining arguments are discrete count variables
        if (x < 0)
            return Double.POSITIVE_INFINITY;
        countSum += x;

        double negativeXLogAlphai;
        if (alphai == 0 && x == 0)
            negativeXLogAlphai = 0;
        else
            negativeXLogAlphai = -x * Math.log(alphai);
        sum += negativeXLogAlphai + org.apache.commons.math3.special.Gamma.logGamma(x + 1);
    }
    if (countSum != _N)
        return Double.POSITIVE_INFINITY;

    final double energy = sum + _N * Math.log(parameterSum);
    if (energy != energy) // Faster isNaN
        return Double.POSITIVE_INFINITY;

    return energy;
}

From source file:jasima.core.statistics.SummaryStat.java

/**
 * Resets this object./* ww w.ja va2s  . com*/
 */
public void clear() {
    meanEst = 0.0;
    varEst = 0.0d;
    numObs = 0;
    weightSum = 0.0d;
    min = Double.POSITIVE_INFINITY;
    max = Double.NEGATIVE_INFINITY;
    lastValue = Double.NaN;
    lastWeight = Double.NaN;
}