根據數組數據源統計出量化級數爲m的直方圖數組

根據數組數據源統計出量化級數爲m的直方圖數組

public class CMath {
    private CMath() {}

    /**
     * Statistical histogram.
     *
     * @param arr value array
     * @param m quantization level
     * @return histogram
     */
    public static int[] histogram(int[] arr, int m) {
        int[] result = new int[m];
        for (int i: arr) {
            if (i < m)
                result[i]++;
        }
        return result;
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章