Example usage for java.lang Double MIN_VALUE

List of usage examples for java.lang Double MIN_VALUE

Introduction

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

Prototype

double MIN_VALUE

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

Click Source Link

Document

A constant holding the smallest positive nonzero value of type double , 2-1074.

Usage

From source file:carskit.alg.cars.transformation.prefiltering.splitting.ItemSplitting.java

public Table<Integer, Integer, Integer> split(SparseMatrix sm, int min) {
    Table<Integer, Integer, Integer> datatable = HashBasedTable.create();

    for (Integer j : itemRatingList.keySet()) {
        Collection<Integer> uis = itemRatingList.get(j);
        double maxt = Double.MIN_VALUE;
        int splitcond = -1;

        for (Integer cond : condContextsList.keySet()) {
            Collection<Integer> ctx = condContextsList.get(cond);
            // start to extract two rating list
            HashMultiset<Double> rate1 = HashMultiset.create();
            HashMultiset<Double> rate2 = HashMultiset.create();

            for (Integer ui : uis) {
                List<Integer> uctx = sm.getColumns(ui);
                for (Integer c : uctx) {
                    double rate = sm.get(ui, c);
                    if (ctx.contains(c))
                        rate1.add(rate);
                    else
                        rate2.add(rate);
                }/*w  w w  .j a  v a  2 s.c  o m*/
            }

            double[] drate1 = Doubles.toArray(rate1);
            double[] drate2 = Doubles.toArray(rate2);

            if (drate1.length >= min && drate2.length >= min) {
                TTest tt = new TTest();
                double p = tt.tTest(drate1, drate2);
                if (p < 0.05) {
                    double t = tt.t(drate1, drate2);
                    if (t > maxt) {
                        // update the split
                        splitcond = cond;
                        maxt = t;
                    }
                }
            }
        }
        if (splitcond != -1) {
            // put u, ctx, new uid into datatable
            int newid = startId++;
            Collection<Integer> ctx = condContextsList.get(splitcond);
            for (Integer c : ctx)
                datatable.put(j, c, newid);
        }

    }
    Logs.info(datatable.rowKeySet().size() + " items have been splitted.");
    return datatable;
}

From source file:net.zypr.api.vo.GeoPositionVO.java

public GeoPositionVO(double[] coordinates) {
    this(coordinates[0], coordinates[1], (coordinates.length == 3 ? coordinates[2] : Double.MIN_VALUE));
}

From source file:carskit.alg.cars.transformation.prefiltering.splitting.UserSplitting.java

public Table<Integer, Integer, Integer> split(SparseMatrix sm, int min) {
    Logs.debug("UserSplitting: startId = " + startId);
    Table<Integer, Integer, Integer> datatable = HashBasedTable.create();

    for (Integer u : userRatingList.keySet()) {
        Collection<Integer> uis = userRatingList.get(u);
        double maxt = Double.MIN_VALUE;
        int splitcond = -1;

        for (Integer cond : condContextsList.keySet()) {
            Collection<Integer> ctx = condContextsList.get(cond);
            // start to extract two rating list
            HashMultiset<Double> rate1 = HashMultiset.create();
            HashMultiset<Double> rate2 = HashMultiset.create();

            for (Integer ui : uis) {
                List<Integer> uctx = sm.getColumns(ui);
                for (Integer c : uctx) {
                    double rate = sm.get(ui, c);
                    if (ctx.contains(c))
                        rate1.add(rate);
                    else
                        rate2.add(rate);
                }//  www  .j  a v  a2  s.c  o m
            }

            double[] drate1 = Doubles.toArray(rate1);
            double[] drate2 = Doubles.toArray(rate2);

            if (drate1.length >= min && drate2.length >= min) {
                TTest tt = new TTest();
                double p = tt.tTest(drate1, drate2);
                if (p < 0.05) {
                    double t = tt.t(drate1, drate2);
                    if (t > maxt) {
                        // update the split
                        splitcond = cond;
                        maxt = t;
                    }
                }
            }
        }

        if (splitcond != -1) {
            // put u, ctx, new uid into datatable
            int newid = startId++;
            Collection<Integer> ctx = condContextsList.get(splitcond);
            for (Integer c : ctx)
                datatable.put(u, c, newid);
        }

    }
    Logs.info(datatable.rowKeySet().size() + " users have been splitted.");
    return datatable;
}

From source file:org.matsim.contrib.util.random.WeightedRandomSelectionTest.java

@Test
public void testIncorrectInput() {
    assertIncorrectWeight(-Double.MIN_VALUE);
    assertIncorrectWeight(-1);//from  w w  w .j ava2 s.  c  o m
    assertIncorrectWeight(-Double.MAX_VALUE);
    assertIncorrectWeight(Double.NEGATIVE_INFINITY);
    assertIncorrectWeight(Double.POSITIVE_INFINITY);
    assertIncorrectWeight(Double.NaN);

    weightedRandomSelection.add("A", 0);
    weightedRandomSelection.add("B", Double.MAX_VALUE);

    assertThatThrownBy(() -> weightedRandomSelection.add(null, Double.MAX_VALUE))//
            .isExactlyInstanceOf(ArithmeticException.class)//
            .hasMessage("Total weight is infinite");
}

From source file:com.sixrr.metrics.ui.charts.DiffHistogramDialog.java

private static boolean isDataIntegral(Double[] datapoints, Double[] prevDatapoints) {
    final double[] strippedData = GraphUtils.stripNulls(datapoints);
    final double[] strippedPrevData = GraphUtils.stripNulls(prevDatapoints);

    boolean isIntegral = true;
    double maximum = Double.MIN_VALUE;
    for (double aStrippedData : strippedData) {
        if (!isIntegral(aStrippedData)) {
            isIntegral = false;/*from  w w w .j a  v a  2 s .  c  o m*/
        }
        maximum = Math.max(maximum, aStrippedData);
    }
    for (double aStrippedPrevData : strippedPrevData) {
        if (!isIntegral(aStrippedPrevData)) {
            isIntegral = false;
        }
        maximum = Math.max(maximum, aStrippedPrevData);
    }
    return isIntegral && maximum < 2 * DEFAULT_BIN_COUNT;
}

From source file:com.devoteam.srit.xmlloader.core.report.derived.StatFlow.java

public StatFlow(long timestamp, long zeroTimestamp, StatKey id, StatCounter counter,
        CounterReportTemplate template) throws ParsingException {
    super(timestamp, zeroTimestamp, counter);
    super.id = id;
    super.template = template;
    this.counter.graphDataset
            .divide((double) this.counter.graphDataset.graphParameters.graphPeriod / (double) 1000);

    this.min = Double.MAX_VALUE;
    this.max = Double.MIN_VALUE;

    double[] array = this.counter.graphDataset.getGraphArray();

    for (int i = 0; i < array.length; i++) {
        double value = array[i];

        if (value < this.min) {
            this.min = value;
        }//from  w  w  w  .j  a va 2s .  c  om
        if (value > this.max) {
            this.max = value;
        }
    }
    init();
}

From source file:co.turnus.common.util.CommonDataUtil.java

public static <T> double maxOf(Map<T, StatisticalData> map) {
    double val = Double.MIN_VALUE;
    for (Entry<T, StatisticalData> s : map.entrySet()) {
        val = FastMath.max(val, s.getValue().getMin());
    }//from w ww  .  java 2 s.  c  om
    return val;
}

From source file:com.basetechnology.s0.agentserver.field.FloatField.java

public static Field fromJson(SymbolTable symbolTable, JSONObject fieldJson) {
    String type = fieldJson.optString("type");
    if (type == null || !type.equals("float"))
        return null;
    String name = fieldJson.has("name") ? fieldJson.optString("name") : null;
    String label = fieldJson.has("label") ? fieldJson.optString("label") : null;
    String description = fieldJson.has("description") ? fieldJson.optString("description") : null;
    double defaultValue = fieldJson.has("default_value") ? fieldJson.optDouble("default_value") : 0;
    double minValue = fieldJson.has("min_value") ? fieldJson.optDouble("min_value") : Double.MIN_VALUE;
    double maxValue = fieldJson.has("max_value") ? fieldJson.optDouble("max_value") : Double.MAX_VALUE;
    int nominalWidth = fieldJson.has("nominal_width") ? fieldJson.optInt("nominal_width") : 0;
    String compute = fieldJson.has("compute") ? fieldJson.optString("compute") : null;
    return new FloatField(symbolTable, name, label, description, defaultValue, minValue, maxValue, nominalWidth,
            compute);//from w  w w . j av a2s.  com
}

From source file:sadl.integration.MonteCarloIntegration.java

public void preprocess(ContinuousDistribution d, double stepSize, double xMin, double xMax) {
    if (d instanceof SingleValueDistribution) {
        singleValueDis = true;/*from   w ww .j ava  2  s  .c  o  m*/
        preprocessed = true;
        return;
    }
    if (Double.isInfinite(xMin)) {
        xMin = Double.MIN_VALUE;
    }
    if (Double.isInfinite(xMax)) {
        xMax = Double.MAX_VALUE;
    }
    final Pair<Double, Double> minMax = findExtreme(d, xMin, xMax, stepSize);
    final double yMin = minMax.getLeft().doubleValue();
    final double yMax = minMax.getRight().doubleValue();
    final double xDiff = xMax - xMin;
    final double yDiff = yMax - yMin;

    int pointsFound = 0;
    int pointsRejected = 0;
    integral = new MonteCarloPoint[pointsToStore];
    while (pointsFound < pointsToStore) {
        final double xSampled = xMin + (xDiff * xRandom.nextDouble());
        final double ySampled = yMin + (yDiff * yRandom.nextDouble());
        final double pdfValue = d.pdf(xSampled);
        if (pdfValue > 0 && ySampled <= pdfValue) {
            // store the point because the sampled y value is smaller than the pdf value at the x value
            integral[pointsFound] = new MonteCarloPoint(xSampled, pdfValue);
            pointsFound++;
        } else {
            pointsRejected++;
        }
    }
    logger.debug("Rejected {} points", pointsRejected);
    logger.debug("Accepted {} points", pointsFound);
    if (Settings.isParallel()) {
        Arrays.parallelSort(integral, new MonteCarloPointComparator());
    } else {
        Arrays.sort(integral, new MonteCarloPointComparator());
    }

    // Collections.sort(integral2);
    // integral2.sort((m1, m2) -> Double.compare(m1.getX(), m2.getX()));
    preprocessed = true;
}

From source file:eu.crisis_economics.abm.algorithms.statistics.TestFloorInterpolator.java

/**
  * Test whether an instance of {@link FloorInterpolator} interpolates
  * a simple discrete input series as expected. This unit test operates
  * as follows:<br><br>/*from   w ww  .ja  v a 2s . co  m*/
  * 
  * {@code (a)}
  *    A short discrete subsequence of the function {@code f(T) = T**2}
  *    is generated;<br>
  * {@code (b)}
  *    An instance of {@link FloorInterpolator} is used to create a
  *   {@link UnivariateFunction}, {@code U}, from this sequence;<br>
  * {@code (c)}
  *    {@code U} is sampled repeatedly for a number of points in the domain
  *    of the input sequence. The results of this operation are compared
  *    to correct, expected outputs.
  */
@Test
public void testFloorInterpolatorOutput() {
    final double[] x = new double[] { 2., 3., 4., 5., 6., }, y = new double[] { 4., 9., 16., 25., 36., };
    final double[] expectedResults = { -Double.MAX_VALUE, 4.000000000, Double.MIN_VALUE, 4.000000000,
            1.000000000, 4.000000000, 1.111111111, 4.000000000, 1.222222222, 4.000000000, 1.333333333,
            4.000000000, 1.444444444, 4.000000000, 1.555555556, 4.000000000, 1.666666667, 4.000000000,
            1.777777778, 4.000000000, 1.888888889, 4.000000000, 2.000000000, 4.000000000, 2.111111111,
            4.000000000, 2.222222222, 4.000000000, 2.333333333, 4.000000000, 2.444444444, 4.000000000,
            2.555555556, 4.000000000, 2.666666667, 4.000000000, 2.777777778, 4.000000000, 2.888888889,
            4.000000000, 3.000000000, 9.000000000, 3.111111111, 9.000000000, 3.222222222, 9.000000000,
            3.333333333, 9.000000000, 3.444444444, 9.000000000, 3.555555556, 9.000000000, 3.666666667,
            9.000000000, 3.777777778, 9.000000000, 3.888888889, 9.000000000, 4.000000000, 16.00000000,
            4.111111111, 16.00000000, 4.222222222, 16.00000000, 4.333333333, 16.00000000, 4.444444444,
            16.00000000, 4.555555556, 16.00000000, 4.666666667, 16.00000000, 4.777777778, 16.00000000,
            4.888888889, 16.00000000, 5.000000000, 25.00000000, 5.111111111, 25.00000000, 5.222222222,
            25.00000000, 5.333333333, 25.00000000, 5.444444444, 25.00000000, 5.555555556, 25.00000000,
            5.666666667, 25.00000000, 5.777777778, 25.00000000, 5.888888889, 25.00000000, 6.000000000,
            36.00000000, 6.111111111, 36.00000000, 6.222222222, 36.00000000, 6.333333333, 36.00000000,
            6.444444444, 36.00000000, 6.555555556, 36.00000000, 6.666666667, 36.00000000, 6.777777778,
            36.00000000, 6.888888889, 36.00000000, 7.000000000, 36.00000000, 7.111111111, 36.00000000,
            7.222222222, 36.00000000, 7.333333333, 36.00000000, 7.444444444, 36.00000000, 7.555555556,
            36.00000000, 7.666666667, 36.00000000, 7.777777778, 36.00000000, 7.888888889, 36.00000000,
            8.000000000, 36.00000000, 8.111111111, 36.00000000, 8.222222222, 36.00000000, 8.333333333,
            36.00000000, 8.444444444, 36.00000000, 8.555555556, 36.00000000, 8.666666667, 36.00000000,
            8.777777778, 36.00000000, 8.888888889, 36.00000000, 9.000000000, 36.00000000, 9.111111111,
            36.00000000, 9.222222222, 36.00000000, 9.333333333, 36.00000000, 9.444444444, 36.00000000,
            9.555555556, 36.00000000, 9.666666667, 36.00000000, 9.777777778, 36.00000000, 9.888888889,
            36.00000000, 10.00000000, 36.00000000, 10.11111111, 36.00000000, 10.22222222, 36.00000000,
            10.33333333, 36.00000000, 10.44444444, 36.00000000, 10.55555556, 36.00000000, 10.66666667,
            36.00000000, 10.77777778, 36.00000000, 10.88888889, 36.00000000, 11.00000000, 36.00000000,
            11.11111111, 36.00000000, 11.22222222, 36.00000000, 11.33333333, 36.00000000, 11.44444444,
            36.00000000, 11.55555556, 36.00000000, 11.66666667, 36.00000000, 11.77777778, 36.00000000,
            11.88888889, 36.00000000, 12.00000000, 36.00000000, Double.MAX_VALUE, 36.00000000 };
    final UnivariateInterpolator interpolator = new FloorInterpolator();
    final UnivariateFunction f = interpolator.interpolate(x, y);
    for (int i = 0; i < expectedResults.length; i += 2) {
        final double t = expectedResults[i], f_t_Observed = f.value(t), f_t_Expected = expectedResults[i + 1];
        System.out.printf("t: %16.10g observed: %16.10g expected: %16.10g\n", t, f_t_Observed, f_t_Expected);
        Assert.assertEquals(f_t_Observed, f_t_Expected, 1.e-12);
    }
}