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.
This commit is contained in:
Родитель
c9add727b4
Коммит
1e8c12067b
|
@ -142,8 +142,8 @@ d3.stats.quantiles = function(d, quantiles) {
|
||||||
return ~~q === q ? (d[q] + d[q + 1]) / 2 : d[Math.round(q)];
|
return ~~q === q ? (d[q] + d[q + 1]) / 2 : d[Math.round(q)];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// TODO: replace with more stable algorithm.
|
// Unbiased estimate of a sample's variance.
|
||||||
// Sample variance.
|
// Also known as the sample variance, where the denominator is n - 1.
|
||||||
d3.stats.variance = function(x) {
|
d3.stats.variance = function(x) {
|
||||||
var mean = d3.stats.mean(x),
|
var mean = d3.stats.mean(x),
|
||||||
n = x.length,
|
n = x.length,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// TODO: replace with more stable algorithm.
|
// Unbiased estimate of a sample's variance.
|
||||||
// Sample variance.
|
// Also known as the sample variance, where the denominator is n - 1.
|
||||||
d3.stats.variance = function(x) {
|
d3.stats.variance = function(x) {
|
||||||
var mean = d3.stats.mean(x),
|
var mean = d3.stats.mean(x),
|
||||||
n = x.length,
|
n = x.length,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче