static/js/numeric.js
/**
 * Return the occurrence of each entry in the input data.
 * @function bincount
 * @param {number[]} arr - input array
 * @return {number[]} the occurrence of each entry in the input data
 * @description Input data must be integers. Output is an array with index as
 * input data and value as frequency.
 * @see numpy.bincount
 */
Return the occurrence of each entry in the input data.
@function bincount
@param {number[]} arr - input array
@return {number[]} the occurrence of each entry in the input data
@description Input data must be integers. Output is an array with index as
input data and value as frequency.
Return the occurrence of each entry in the input data . @function bincount @param { number [] } arr - input array @return { number [] } the occurrence of each entry in the input data @description Input data must be integers . Output is an array with index as input data and value as frequency .
function bincount(arr) {
  const res = Array(Math.max(...arr) + 1).fill(0);
  const n = arr.length;
  for (let i = 0; i < n; i++) {
    res[arr[i]]++;
  }
  return res;
}
function bincount ( arr ) { const res = Array ( Math . max ( ... arr ) + 1 ) . fill ( 0 ) ; const n = arr . length ; for ( let i = 0 ; i < n ; i ++ ) { res [ arr [ i ] ] ++ ; } return res ; }
Return the occurrence of each entry in the input data.
Return the occurrence of each entry in the input data .