src/main/java/com/xceptance/neodymium/visual/ai/image/HistogramStatistics.java
/**
     * Get range around median containing specified percentage of values.
     * 
     * @param values
     *            Values.
     * @param percent
     *            Values percentage around median.
     * @return Returns the range which contains specified percentage of values.
     */
Get range around median containing specified percentage of values.

@param values
Values.
@param percent
Values percentage around median.
@return Returns the range which contains specified percentage of values.
Get range around median containing specified percentage of values . @param values Values . @param percent Values percentage around median . @return Returns the range which contains specified percentage of values .
public static IntRange GetRange(int[] values, double percent)
    {
        int total = 0, n = values.length;
        for (int i = 0; i < n; i++)
        {
            total += values[i];
        }
        int min, max, hits;
        int h = (int) (total * (percent + (1 - percent) / 2));
        for (min = 0, hits = total; min < n; min++)
        {
            hits -= values[min];
            if (hits < h)
                break;
        }
        for (max = n - 1, hits = total; max >= 0; max--)
        {
            hits -= values[max];
            if (hits < h)
                break;
        }
        return new IntRange(min, max);
    }
public static IntRange GetRange ( int [ ] values , double percent ) { int total = 0 , n = values . length ; for ( int i = 0 ; i < n ; i ++ ) { total += values [ i ] ; } int min , max , hits ; int h = ( int ) ( total * ( percent + ( 1 - percent ) / 2 ) ) ; for ( min = 0 , hits = total ; min < n ; min ++ ) { hits -= values [ min ] ; if ( hits < h ) break ; } for ( max = n - 1 , hits = total ; max >= 0 ; max -- ) { hits -= values [ max ] ; if ( hits < h ) break ; } return new IntRange ( min , max ) ; }
Get range around median containing specified percentage of values.
Get range around median containing specified percentage of values .
// for all values // accumulate total // get range min value // get range max value