Java mean mean(final double[] expected, final int begin, final int end)

Here you can find the source of mean(final double[] expected, final int begin, final int end)

Description

mean

License

Open Source License

Declaration

public static double mean(final double[] expected, final int begin, final int end) 

Method Source Code

//package com.java2s;
/**//from  w w  w  .  ja v  a2s  .c  o m
 * Copyright? 2014-2016 LIST (Luxembourg Institute of Science and Technology), all right reserved.
 * Authorship : Olivier PARISOT, Yoanne DIDRY
 * Licensed under GNU General Public License version 3
 */

public class Main {
    public static double mean(final double[] expected, final int begin, final int end) {
        int trueN = 0;
        double mean = 0d;
        for (int i = Math.max(0, begin); i < Math.min(expected.length - 1, end); i++) {
            mean += expected[i];
            trueN++;
        }

        if (trueN == 0)
            throw new IllegalStateException();

        mean /= (double) trueN;

        return mean;
    }
}

Related

  1. mean(double[][] input, int column)
  2. mean(double[][] matrix)
  3. mean(double[][] o)
  4. mean(final double[] a)
  5. mean(final double[] data, final boolean noNaN)
  6. mean(final double[] in, final int start, final int stop)
  7. mean(final double[] values)
  8. mean(final double[] vec)
  9. mean(final int[] scores)