Java Array Average avg(double[] x, int start, int end)

Here you can find the source of avg(double[] x, int start, int end)

Description

avg

License

Apache License

Declaration

public static double avg(double[] x, int start, int end) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double avg(double[] x, int start, int end) {
        if (start >= end) {
            return 0;
        }/*from w w  w  .jav a  2  s .com*/
        return sum(x, start, end) / (end - start);
    }

    public static double sum(double[] x, int start, int end) {
        double sum = 0;
        for (int i = start; i < end; i++) {
            sum += x[i];
        }
        return sum;
    }
}

Related

  1. avg(double[] a)
  2. avg(double[] array)
  3. avg(double[] nums)
  4. avg(double[] values)
  5. avg(double[] values)
  6. avg(final double a, final double b)
  7. avg(final double... values)
  8. avg(float... numbers)
  9. avg(int... values)