src/stats/frequencies.js
function frequencies(sequence) {
  const index = {};

  // Handling strings
  sequence = seq(sequence);

  for (let i = 0, l = sequence.length; i < l; i++) {
    const element = sequence[i];

    if (!index[element])
      index[element] = 0;
    index[element]++;
  }

  return index;
}
function frequencies(sequence) {
  const index = {};

  // Handling strings
  sequence = seq(sequence);

  for (let i = 0, l = sequence.length; i < l; i++) {
    const element = sequence[i];

    if (!index[element])
      index[element] = 0;
    index[element]++;
  }

  return index;
}
function frequencies ( sequence ) { const index = { } ; // Handling strings sequence = seq ( sequence ) ; for ( let i = 0 , l = sequence . length ; i < l ; i ++ ) { const element = sequence [ i ] ; if ( ! index [ element ] ) index [ element ] = 0 ; index [ element ] ++ ; } return index ; }
Function taking a sequence and computing its frequencies.

@param  {mixed}  sequence - The sequence to process.
@return {object}          - A dict of the sequence's frequencies.

@example
// frequencies([1, 1, 2, 3, 3, 3]) => {1: 2, 2: 1, 3: 3}
// frequencies('test') => {t: 2, e: 1, s: 1}
Function taking a sequence and computing its frequencies .