Example usage for java.lang Double NEGATIVE_INFINITY

List of usage examples for java.lang Double NEGATIVE_INFINITY

Introduction

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

Prototype

double NEGATIVE_INFINITY

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

Click Source Link

Document

A constant holding the negative infinity of type double .

Usage

From source file:beast.math.distributions.NegativeBinomialDistribution.java

public double logPdf(double x) {
    if (x < 0)
        return Double.NEGATIVE_INFINITY;
    double r = -1 * (mean * mean) / (mean - stdev * stdev);
    double p = mean / (stdev * stdev);
    return Math.log(Math.pow(1 - p, x)) + Math.log(Math.pow(p, r)) + GammaFunction.lnGamma(r + x)
            - GammaFunction.lnGamma(r) - GammaFunction.lnGamma(x + 1);
}

From source file:ml.shifu.shifu.core.binning.obj.NumBinInfo.java

public static List<NumBinInfo> constructNumBinfo(String binsData, char fieldSeparator) {
    List<NumBinInfo> binInfos = new ArrayList<NumBinInfo>();

    List<Double> thresholds = new ArrayList<Double>();
    thresholds.add(Double.NEGATIVE_INFINITY);

    if (StringUtils.isNotBlank(binsData)) {
        String[] fields = StringUtils.split(binsData, fieldSeparator);
        if (fields != null) {
            for (String field : fields) {
                Double val = null;
                try {
                    val = Double.valueOf(field);
                    thresholds.add(val);
                } catch (Exception e) {
                    // skip illegal double
                }/*w  w  w.  j  a  v a2s  .c om*/
            }
        }
    }

    thresholds.add(Double.POSITIVE_INFINITY);
    Collections.sort(thresholds);

    for (int i = 0; i < thresholds.size() - 1; i++) {
        binInfos.add(new NumBinInfo(thresholds.get(i), thresholds.get(i + 1)));
    }

    return binInfos;
}

From source file:edu.byu.nlp.math.RealVectors.java

/**
 * Computes the log of the sum of the exponentiated elements of a vector. For any index j:
 * //from   w w  w. j  a  v a  2  s  .c  o  m
 * <pre>
 * log(e^{x_1} + e^{x_2} + ...) = log(e^{x_j} * sum\_{i \neq j} e^{x_i - x_j} + 1)
  *                              = x_j + log(sum\_{i \neq j} e^{x_i - x_j} + 1)
  * </pre>
  * 
  * This method ignores elements that are twenty orders of magnitude different than x_j.
  * 
  * @throws NullPointerException if vector is null
  */
public static double logSumSloppy(RealVector x) {
    Preconditions.checkNotNull(x);

    // TODO(rah67): consider just using the first element
    // use max as j
    int argMax = x.getMaxIndex();
    double max = x.getEntry(argMax);

    if (max == Double.NEGATIVE_INFINITY)
        return Double.NEGATIVE_INFINITY;

    return DoubleArrays.logSum(x.toArray());
}

From source file:fr.inria.oak.paxquery.pact.operations.aggregation.Max.java

public Max(MetadataTypes type) {
    this.type = type;

    switch (this.type) {
    case STRING_TYPE:
        this.maxDouble = Double.NEGATIVE_INFINITY;
        break;//from  ww  w . j  a v  a 2 s  .c o m
    default:
        logger.error("Max aggregation not supported for this data type!");
    }

    this.count = 0;
}

From source file:com.rapidminer.gui.plotter.charts.ColorizedBarRenderer.java

public ColorizedBarRenderer(double[] colorValues) {
    this.colorValues = colorValues;
    this.minColor = Double.POSITIVE_INFINITY;
    this.maxColor = Double.NEGATIVE_INFINITY;
    if (this.colorValues != null) {
        for (double d : this.colorValues) {
            this.minColor = MathFunctions.robustMin(this.minColor, d);
            this.maxColor = MathFunctions.robustMax(this.maxColor, d);
        }/*from  ww w  .  j  a  v  a 2 s .c o  m*/
    }
}

From source file:com.rapidminer.gui.plotter.charts.ColorizedBubbleRenderer.java

public ColorizedBubbleRenderer(double[] colors) {
    super(XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    this.minColor = Double.POSITIVE_INFINITY;
    this.maxColor = Double.NEGATIVE_INFINITY;
    for (double c : colors) {
        minColor = MathFunctions.robustMin(minColor, c);
        maxColor = MathFunctions.robustMax(maxColor, c);
    }//from   w  w  w  .jav a  2s  .co m
    this.colors = colors;
}

From source file:ch.ethz.bsse.quasirecomb.informationholder.ModelSelectionBootstrapStorage.java

private void select() {
    double maxValue = Double.NEGATIVE_INFINITY;
    int maxK = 0;
    for (Map.Entry<Integer, SelectionResultBootstrap> entry : srMap.entrySet()) {
        SelectionResultBootstrap srTmp = entry.getValue();
        if (maxValue < srTmp.median) {
            maxValue = srTmp.median;/*from ww w  .  ja va2 s.co  m*/
            maxK = entry.getKey();
        }
    }
    if (maxK == Globals.getINSTANCE().getK_MIN()) {
        this.bestK = maxK;
    } else {
        while (maxK - 1 > 0) {
            if (srMap.containsKey(maxK - 1)) {
                SelectionResultBootstrap previous = srMap.get(maxK - 1);
                if (srMap.get(maxK).median < previous.lowerBound) {
                    maxK--;
                } else {
                    this.bestK = maxK;
                    break;
                }
            }
        }
    }
}

From source file:com.clust4j.kernel.LogKernel.java

@Override
public double getSimilarity(final double[] a, final double[] b) {
    final double sup = -(super.getSimilarity(a, b)); // super returns negative, so reverse it
    final double answer = -FastMath.log(sup + 1);
    return Double.isNaN(answer) ? Double.NEGATIVE_INFINITY : answer;
}

From source file:Main.java

/**
 * Fills the array with random doubles.  Values will be between min (inclusive) and
 * max (inclusive).//from w  ww.j a  v  a  2  s.c  o m
 */
public static void genRandomDoubles(long seed, double min, double max, double array[],
        boolean includeExtremes) {
    Random r = new Random(seed);
    int minExponent = Math.min(Math.getExponent(min), 0);
    int maxExponent = Math.max(Math.getExponent(max), 0);
    if (minExponent < -6 || maxExponent > 6) {
        // Use an exponential distribution
        int exponentDiff = maxExponent - minExponent;
        for (int i = 0; i < array.length; i++) {
            double mantissa = r.nextDouble();
            int exponent = minExponent + r.nextInt(maxExponent - minExponent);
            int sign = (min >= 0) ? 1 : 1 - r.nextInt(2) * 2; // -1 or 1
            double rand = sign * mantissa * Math.pow(2.0, exponent);
            if (rand < min || rand > max) {
                continue;
            }
            array[i] = rand;
        }
    } else {
        // Use a linear distribution
        for (int i = 0; i < array.length; i++) {
            double rand = r.nextDouble();
            array[i] = min + rand * (max - min);
        }
    }
    // Seed a few special numbers we want to be sure to test.
    for (int i = 0; i < sInterestingDoubles.length; i++) {
        double d = sInterestingDoubles[i];
        if (min <= d && d <= max) {
            array[r.nextInt(array.length)] = d;
        }
    }
    array[r.nextInt(array.length)] = min;
    array[r.nextInt(array.length)] = max;
    if (includeExtremes) {
        array[r.nextInt(array.length)] = Double.NaN;
        array[r.nextInt(array.length)] = Double.POSITIVE_INFINITY;
        array[r.nextInt(array.length)] = Double.NEGATIVE_INFINITY;
        array[r.nextInt(array.length)] = Double.MIN_VALUE;
        array[r.nextInt(array.length)] = Double.MIN_NORMAL;
        array[r.nextInt(array.length)] = Double.MAX_VALUE;
        array[r.nextInt(array.length)] = -Double.MIN_VALUE;
        array[r.nextInt(array.length)] = -Double.MIN_NORMAL;
        array[r.nextInt(array.length)] = -Double.MAX_VALUE;
    }
}

From source file:aos.creditassignment.setimprovement.MedianIndicatorImprovement.java

/**
 * Assumes that the offspring is the last index in the population. Returns
 * the difference between the mean fitness of the population and the
 * offspring fitness. If it is negative, it returns 0
 *
 * @param offspring solution that will receive credits
 * @param population the population to compare the offspring solutions with
 * @return the value of credit to resulting from the solution
 *///from w w  w.j a  v a2 s .  c  o  m
@Override
public double compute(Solution offspring, Population population) {

    double[] fitnessvals = new double[population.size()];
    double minFitness = Double.POSITIVE_INFINITY;
    double maxFitness = Double.NEGATIVE_INFINITY;
    //find sum of the fitness minus the offspring
    for (int i = 0; i < population.size() - 1; i++) {
        fitnessvals[i] = (double) population.get(i).getAttribute(FitnessEvaluator.FITNESS_ATTRIBUTE);
        minFitness = Math.min(minFitness, fitnessvals[i]);
        maxFitness = Math.max(maxFitness, fitnessvals[i]);
    }
    double median = medianCompute.evaluate(fitnessvals, 50.0);
    double offspringFit = (double) offspring.getAttribute(FitnessEvaluator.FITNESS_ATTRIBUTE);
    return Math.max((median - offspringFit) / (median - minFitness), 0.0);
}