Here you can find the source of calculateMeanLevel(float[] distribution, int mid, int oldMid, float difference)
@Deprecated public static int calculateMeanLevel(float[] distribution, int mid, int oldMid, float difference)
//package com.java2s; //License from project: Open Source License public class Main { @Deprecated public static int calculateMeanLevel(float[] distribution, int mid, int oldMid, float difference) { return calculateMeanLevel(distribution, mid); }//from ww w . java 2 s.co m /** * @param distribution the target array * @param mid the "best guess" of the midpoint * @return the mid level of the distribution */ public static int calculateMeanLevel(float[] distribution, int mid) { float adjacent = 0; float maxAdjacent = 0; int consecutive = 0; mid = 0; for (int i = 0; i < 4 && i < distribution.length; i++) adjacent += distribution[i]; for (int i = 0; i < distribution.length - 4; i++) { adjacent -= distribution[i] - distribution[i + 4]; if (adjacent > maxAdjacent) { mid = i + 2; maxAdjacent = adjacent + 0.00001f; consecutive = 0; } else if (adjacent > maxAdjacent - 0.00002f) { consecutive++; } else { mid += consecutive / 2; consecutive = 0; } } return mid; } }