Java mean mean(float[] a, int off, int length)

Here you can find the source of mean(float[] a, int off, int length)

Description

mean

License

Open Source License

Declaration

public static float mean(float[] a, int off, int length) 

Method Source Code

//package com.java2s;
/*//ww  w .  jav a2  s .c o m
 *  Util.java
 *  (FScape)
 *
 *  Copyright (c) 2001-2015 Hanns Holger Rutz. All rights reserved.
 *
 *  This software is published under the GNU General Public License v3+
 *
 *
 *   For further information, please contact Hanns Holger Rutz at
 *   contact@sciss.de
 *
 *
 *  Changelog:
 *      17-Jun-07   extended
 */

public class Main {
    public static float mean(float[] a, int off, int length) {
        return sum(a, off, length) / length;
    }

    public static float sum(float[] a, int off, int length) {
        double d = 0.0;
        final int stop = off + length;
        while (off < stop)
            d += a[off++];
        return (float) d;
    }
}

Related

  1. mean(final double[] values)
  2. mean(final double[] vec)
  3. mean(final int[] scores)
  4. mean(final int[] values)
  5. mean(float a, float b)
  6. mean(float[] arr)
  7. mean(float[] array)
  8. mean(float[] xs)
  9. mean(int low, int high)