The input array is treated as histogram, i.e. its indexes are treated as values of stochastic function, but array values are treated as "probabilities" (total amount of hits).
Returns the minimum mode value if the specified histogram is multimodal.
public static int HistogramMode(this int[] values) { int mode = 0, curMax = 0; for (int i = 0; i < values.Length; i++) { if (values[i] > curMax) { curMax = values[i]; mode = i; } } return mode; } }