Java Array Min Value min(double[] series)

Here you can find the source of min(double[] series)

Description

Finds the minimal value in timeseries.

License

Open Source License

Parameter

Parameter Description
series The timeseries.

Return

The min value.

Declaration

public static double min(double[] series) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*ww w .  j  av  a  2  s .  c o m*/
     * Finds the minimal value in timeseries.
     *
     * @param series The timeseries.
     * @return The min value.
     */
    public static double min(double[] series) {
        if (countNaN(series) == series.length) {
            return Double.NaN;
        }
        double min = Double.MAX_VALUE;
        for (int i = 0; i < series.length; i++) {
            if (min > series[i]) {
                min = series[i];
            }
        }
        return min;
    }

    /**
     * Counts the number of NaNs' in the timeseries.
     *
     * @param series The timeseries.
     * @return The count of NaN values.
     */
    private static int countNaN(double[] series) {
        int res = 0;
        for (double d : series) {
            if (Double.isInfinite(d) || Double.isNaN(d)) {
                res += 1;
            }
        }
        return res;
    }
}

Related

  1. min(double[] array)
  2. min(double[] da)
  3. min(double[] data)
  4. min(double[] matrix)
  5. min(double[] numbers)
  6. min(double[] vals)
  7. min(double[] values)
  8. min(double[] values)
  9. min(double[] values)