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:Main.java

/** Determines the maximum y-coordinate for the set of points.
 * @param points//from  w w w. j  a va2s . c o m
 * @return the maximum y-coordinate of the points
 */
public static double maxY(Point2D[] points) {
    double maxY = Double.MIN_VALUE;
    for (Point2D point : points) {
        if (point.getY() > maxY) {
            maxY = point.getY();
        }
    }
    return maxY;
}

From source file:Main.java

public static void getTop(ArrayList<Double> array, ArrayList<Integer> rankList, int i) {
    int index = 0;
    HashSet<Integer> scanned = new HashSet<Integer>();
    Double max = Double.MIN_VALUE;
    for (int m = 0; m < i && m < array.size(); m++) {
        max = Double.MIN_VALUE;/*ww w . j av a2 s  .c o  m*/
        for (int no = 0; no < array.size(); no++) {
            if (!scanned.contains(no)) {
                if (array.get(no) > max) {
                    index = no;
                    max = array.get(no);
                } else if (array.get(no).equals(max) && Math.random() > 0.5) {
                    index = no;
                    max = array.get(no);
                }
            }
        }
        if (!scanned.contains(index)) {
            scanned.add(index);
            rankList.add(index);
        }
        //System.out.println(m + "\t" + index);
    }
}

From source file:org.talend.dataquality.duplicating.DistributionFactory.java

public static AbstractIntegerDistribution createDistribution(String name, double expectation) {
    AbstractIntegerDistribution distro = null;
    if (expectation < 2) {
        throw new IllegalArgumentException("The expectation value must be greater than or equals to 2"); //$NON-NLS-1$
    }//from ww  w.  j  a v a2s .co  m
    if (name.equals("BERNOULLI")) { //$NON-NLS-1$
        distro = new BinomialDistribution((int) ((expectation - 2) * 2), 0.5);
    } else if (name.equals("GEOMETRIC")) { //$NON-NLS-1$
        distro = new GeometricDistribution(1 / (expectation - 1));
    } else if (name.equals("POISSON")) { //$NON-NLS-1$
        distro = new PoissonDistribution(expectation - 2 + java.lang.Double.MIN_VALUE);
    }
    return distro;
}

From source file:net.dontdrinkandroot.utils.collections.CollectionUtils.java

public static <T extends Number> AggregationResult aggregate(final Collection<T> collection) {

    if (collection.isEmpty()) {
        throw new IllegalArgumentException("Collection must not be empty");
    }/*from   w  w w  .  j  av a2s  . c  om*/

    final AggregationResult result = new AggregationResult();
    result.setSize(collection.size());
    double sum = 0;
    double min = Double.MAX_VALUE;
    double max = Double.MIN_VALUE;

    /* Determine min, max, sum */
    for (final T entry : collection) {
        if (entry != null) {
            final double value = entry.doubleValue();
            max = Math.max(max, value);
            min = Math.min(min, value);
            sum += value;
        }
    }
    result.setMin(min);
    result.setMax(max);
    result.setSum(sum);

    result.setAvg(sum / result.getSize());

    result.setMean(CollectionUtils.getMean(collection));

    return result;
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    contentPane = new JPanel();

    setContentPane(contentPane);/* w  w  w .  j a v  a2  s  . com*/
    GridBagLayout gbl_panel = new GridBagLayout();
    gbl_panel.columnWidths = new int[] { 0, 0, 0, 0 };
    gbl_panel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0 };
    gbl_panel.columnWeights = new double[] { 0.0, 0.1, 0.0, Double.MIN_VALUE };
    gbl_panel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };

    contentPane.setLayout(gbl_panel);

    JButton btn_1 = new JButton("B1");
    GridBagConstraints gbc_comboBox = new GridBagConstraints();
    gbc_comboBox.insets = new Insets(0, 0, 5, 20);
    gbc_comboBox.gridx = 2;
    gbc_comboBox.gridy = 0;
    gbc_comboBox.weightx = 0.0;
    contentPane.add(btn_1, gbc_comboBox);

    JButton btn_2 = new JButton("B2");
    GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
    gbc_btnNewButton.insets = new Insets(0, 0, 5, 20);
    gbc_btnNewButton.gridx = 2;
    gbc_btnNewButton.gridy = 1;
    contentPane.add(btn_2, gbc_btnNewButton);
    setSize(200, 300);
}

From source file:Main.java

/**
 * Get the next machine representable number after a number, moving
 * in the direction of another number.//  w ww  .ja va  2 s . co m
 * <p>
 * If <code>direction</code> is greater than or equal to<code>d</code>,
 * the smallest machine representable number strictly greater than
 * <code>d</code> is returned; otherwise the largest representable number
 * strictly less than <code>d</code> is returned.</p>
 * <p>
 * If <code>d</code> is NaN or Infinite, it is returned unchanged.</p>
 * 
 * @param d base number
 * @param direction (the only important thing is whether
 * direction is greater or smaller than d)
 * @return the next machine representable number in the specified direction
 * @since 1.2
 */
public static double nextAfter(double d, double direction) {

    // handling of some important special cases
    if (Double.isNaN(d) || Double.isInfinite(d)) {
        return d;
    } else if (d == 0) {
        return (direction < 0) ? -Double.MIN_VALUE : Double.MIN_VALUE;
    }
    // special cases MAX_VALUE to infinity and  MIN_VALUE to 0
    // are handled just as normal numbers

    // split the double in raw components
    long bits = Double.doubleToLongBits(d);
    long sign = bits & 0x8000000000000000L;
    long exponent = bits & 0x7ff0000000000000L;
    long mantissa = bits & 0x000fffffffffffffL;

    if (d * (direction - d) >= 0) {
        // we should increase the mantissa
        if (mantissa == 0x000fffffffffffffL) {
            return Double.longBitsToDouble(sign | (exponent + 0x0010000000000000L));
        } else {
            return Double.longBitsToDouble(sign | exponent | (mantissa + 1));
        }
    } else {
        // we should decrease the mantissa
        if (mantissa == 0L) {
            return Double.longBitsToDouble(sign | (exponent - 0x0010000000000000L) | 0x000fffffffffffffL);
        } else {
            return Double.longBitsToDouble(sign | exponent | (mantissa - 1));
        }
    }

}

From source file:br.unicamp.ic.recod.gpsi.measures.gpsiNormalBhattacharyyaDistanceScore.java

@Override
public double score(double[][][] input) {

    Mean mean = new Mean();
    Variance var = new Variance();

    double mu0, sigs0, mu1, sigs1;
    double dist[][] = new double[2][];

    dist[0] = MatrixUtils.createRealMatrix(input[0]).getColumn(0);
    dist[1] = MatrixUtils.createRealMatrix(input[1]).getColumn(0);

    mu0 = mean.evaluate(dist[0]);//from   w ww. jav  a2 s.co m
    sigs0 = var.evaluate(dist[0]) + Double.MIN_VALUE;
    mu1 = mean.evaluate(dist[1]);
    sigs1 = var.evaluate(dist[1]) + Double.MIN_VALUE;

    double distance = (Math.log((sigs0 / sigs1 + sigs1 / sigs0 + 2) / 4)
            + (Math.pow(mu1 - mu0, 2.0) / (sigs0 + sigs1))) / 4;

    return distance == Double.POSITIVE_INFINITY ? 0 : distance;

}

From source file:pybot.math.SetOfDoubles.java

public String refresh() {
    min = Double.MAX_VALUE;/*from  w  w  w.jav  a2  s .  c om*/
    max = Double.MIN_VALUE;
    length = set.length;

    Double s = 0.0;
    for (Double d : set) {
        s += d;
        if (d < min) {
            min = d;
        }
        if (d > max) {
            max = d;
        }
    }
    sum = s;
    range = max - min;
    average = sum / length;

    Double var = 0.0;
    for (Double d : set) {
        var = (d - average) * (d - average);
    }
    var /= (length - 1);
    variance = var;

    standardDeviation = sqrt(variance);

    return setName + " has been refreshed!";
}

From source file:mzmatch.ipeak.align.CowCoda.java

/**
 * /*  ww  w .  j  a  va 2  s . c  o m*/
 * @param peak
 * @return
 * @throws RuntimeException
 */
@SuppressWarnings("unchecked")
public static double maxRT(IPeak peak) throws RuntimeException {
    if (peak.getClass().equals(IPeakSet.class)) {
        IPeakSet<IPeak> peakset = (IPeakSet<IPeak>) peak;
        double maxrt = Double.MIN_VALUE;
        for (IPeak p : peakset)
            maxrt = Math.max(maxrt, maxRT(p));
        return maxrt;
    } else if (peak.getClass().equals(MassChromatogram.class))
        return ((MassChromatogram<Peak>) peak).getMaxRetentionTime();
    throw new RuntimeException("Only type MassChromatogram or PeakSet are supported");
}

From source file:com.versobit.weatherdoge.WeatherUtil.java

static WeatherResult getWeather(String location, Source source) {
    return getWeather(Double.MIN_VALUE, Double.MIN_VALUE, location, source);
}