Here you can find the source of meanWithoutZerosCentered(int[] in, int center, int width)
static public double meanWithoutZerosCentered(int[] in, int center, int width)
//package com.java2s; //License from project: Open Source License public class Main { static public double meanWithoutZerosCentered(int[] in, int center, int width) { if (in.length > width) { double res = 0; int i = 1; int k = 1; res = in[center];//from w w w . j a va2 s .c o m while (k < width && (center + i < in.length || center - i > 0)) { if (center + i < in.length && in[center + i] != 0) { res += in[center + i]; k++; } if (center - i > 0 && in[center - i] != 0) { res += in[center - i]; k++; } i++; } return res * 1.0 / k; } else { System.out.println("faute meanzerocentered"); return in[center]; } } }