Commit 36b70ae1 authored by leighton@cis.udel.edu's avatar leighton@cis.udel.edu

The benchmarking tool calculates the population variance rather than the sample variance.

Since benchmarking results represent only a sample of the entire population of
results, it would be better to calculate the sample standard deviation, which
is an unbiased estimator of the population variance.  Also, since the Array.avg
function throws out the min and max, this function should not be used when
calculating the variance.

BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7108006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88379 0039d316-1c4b-4281-b951-d872f2087c98
parent 45941772
......@@ -162,16 +162,20 @@ Array.avg = function(array) {
return sum / count;
}
// Compute the standard deviation of an array
// Compute the sample standard deviation of an array
Array.stddev = function(array) {
var count = array.length;
var mean = Array.avg(array);
var mean = 0;
for (var i = 0; i < count; i++) {
mean += array[i];
}
mean /= count;
var variance = 0;
for (var i = 0; i < count; i++) {
var deviation = mean - array[i];
variance = variance + deviation * deviation;
}
variance = variance / count;
variance = variance / (count - 1);
return Math.sqrt(variance);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment