src/stats/inferential.js
function genericVariance(ddof, sequence) {
  const length = sequence.length;

  if (!length)
    throw Error('talisman/stats/inferential#variance: the given list is empty.');

  // Returning 0 if the denominator would be <= 0
  const denominator = length - ddof;

  if (denominator <= 0)
    return 0;

  const m = mean(sequence);

  let s = 0;

  for (let i = 0; i < length; i++)
    s += Math.pow(sequence[i] - m, 2);

  return s / denominator;
}
function genericVariance(ddof, sequence) {
  const length = sequence.length;

  if (!length)
    throw Error('talisman/stats/inferential#variance: the given list is empty.');

  // Returning 0 if the denominator would be <= 0
  const denominator = length - ddof;

  if (denominator <= 0)
    return 0;

  const m = mean(sequence);

  let s = 0;

  for (let i = 0; i < length; i++)
    s += Math.pow(sequence[i] - m, 2);

  return s / denominator;
}
function genericVariance ( ddof , sequence ) { const length = sequence . length ; if ( ! length ) throw Error ( 'talisman/stats/inferential#variance: the given list is empty.' ) ; // Returning 0 if the denominator would be <= 0 const denominator = length - ddof ; if ( denominator <= 0 ) return 0 ; const m = mean ( sequence ) ; let s = 0 ; for ( let i = 0 ; i < length ; i ++ ) s += Math . pow ( sequence [ i ] - m , 2 ) ; return s / denominator ; }
Function computing the sample variance of the given sequence.

@param  {number}  ddof     - Delta degrees of freedom.
@param  {array}   sequence - The sequence to process.
@return {number}           - The variance.

@throws {Error} - The function expects a non-empty list.
Function computing the sample variance of the given sequence .