Chromium Code Reviews| Index: tools/telemetry/third_party/WebKit/PerformanceTests/resources/statistics.js |
| diff --git a/tools/telemetry/third_party/WebKit/PerformanceTests/resources/statistics.js b/tools/telemetry/third_party/WebKit/PerformanceTests/resources/statistics.js |
| index f5269c2c2b8769e43c65fc1c090d548a83b54520..4ed70d7fe24bd7caa82f42ab69177dbd8f6321fc 100644 |
| --- a/tools/telemetry/third_party/WebKit/PerformanceTests/resources/statistics.js |
| +++ b/tools/telemetry/third_party/WebKit/PerformanceTests/resources/statistics.js |
| @@ -65,8 +65,7 @@ var Statistics = new (function () { |
| return supportedLevels; |
| } |
| - // Computes the delta d s.t. (mean - d, mean + d) is the confidence interval with the specified confidence level in O(1). |
| - this.confidenceIntervalDelta = function (confidenceLevel, numberOfSamples, sum, squareSum) { |
| + this.quantile = function (confidenceLevel, numberOfSamples) { |
| var probability = (1 - (1 - confidenceLevel) / 2); |
| if (!(probability in tDistributionInverseCDF)) { |
| console.warn('We only support ' + this.supportedConfidenceLevels().map( |
| @@ -81,16 +80,27 @@ var Statistics = new (function () { |
| // tDistributionQuantile(degreesOfFreedom, confidenceLevel) * sampleStandardDeviation / sqrt(numberOfSamples) * S/sqrt(numberOfSamples) |
| if (degreesOfFreedom <= 100) |
| - var quantile = cdfForProbability[degreesOfFreedom - 1]; // The first entry is for the one degree of freedom. |
| + return cdfForProbability[degreesOfFreedom - 1]; // The first entry is for the one degree of freedom. |
| else if (degreesOfFreedom <= 300) |
| - var quantile = cdfForProbability[Math.round(degreesOfFreedom / 10) + 100 - 10 - 1]; |
| + return cdfForProbability[Math.round(degreesOfFreedom / 10) + 100 - 10 - 1]; |
| else if (degreesOfFreedom <= 1300) |
| - var quantile = cdfForProbability[Math.round(degreesOfFreedom / 100) + 120 - 3 - 1]; |
| + return cdfForProbability[Math.round(degreesOfFreedom / 100) + 120 - 3 - 1]; |
| else |
| - var quantile = cdfForProbability[cdfForProbability.length - 1]; |
| + return cdfForProbability[cdfForProbability.length - 1]; |
| + } |
| + |
| + // Computes the delta d s.t. (mean - d, mean + d) is the confidence interval with the specified confidence level in O(1). |
| + this.confidenceIntervalDelta = function (confidenceLevel, numberOfSamples, sum, squareSum) { |
|
petrcermak
2015/09/09 18:44:40
To reduce code duplication, this function should u
nednguyen
2015/09/09 22:29:06
Done.
|
| + var quantile = this.quantile(confidenceLevel, numberOfSamples); |
| return quantile * this.sampleStandardDeviation(numberOfSamples, sum, squareSum) / Math.sqrt(numberOfSamples); |
| } |
| + this.confidenceIntervalDeltaFromStd = function (confidenceLevel, numberOfSamples, sampleStandardDeviation) { |
| + var quantile = this.quantile(confidenceLevel, numberOfSamples); |
| + return quantile * sampleStandardDeviation / Math.sqrt(numberOfSamples); |
| + } |
| + |
| + |
| this.confidenceInterval = function (values, probability) { |
| var sum = this.sum(values); |
| var mean = sum / values.length; |