From 1e8c12067bb3dff40458b20c9dffe819b3bec1e2 Mon Sep 17 00:00:00 2001 From: Jason Davies Date: Wed, 11 May 2011 16:52:37 +0100 Subject: [PATCH] Clarify d3.stats.variance. Remove TODO comment as this seems numerically robust enough. The same two-pass algorithm is used in Haskell's "statistics" package. --- d3.stats.js | 4 ++-- src/stats/variance.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/d3.stats.js b/d3.stats.js index 3ed8e942..a96a6986 100644 --- a/d3.stats.js +++ b/d3.stats.js @@ -142,8 +142,8 @@ d3.stats.quantiles = function(d, quantiles) { return ~~q === q ? (d[q] + d[q + 1]) / 2 : d[Math.round(q)]; }); }; -// TODO: replace with more stable algorithm. -// Sample variance. +// Unbiased estimate of a sample's variance. +// Also known as the sample variance, where the denominator is n - 1. d3.stats.variance = function(x) { var mean = d3.stats.mean(x), n = x.length, diff --git a/src/stats/variance.js b/src/stats/variance.js index 21ebbd2b..fbd08f04 100644 --- a/src/stats/variance.js +++ b/src/stats/variance.js @@ -1,5 +1,5 @@ -// TODO: replace with more stable algorithm. -// Sample variance. +// Unbiased estimate of a sample's variance. +// Also known as the sample variance, where the denominator is n - 1. d3.stats.variance = function(x) { var mean = d3.stats.mean(x), n = x.length,