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..faa5a4aa7988bda6347bd5234711149a50ae7b58 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, opt_degreeOfFreedom) { |
| var probability = (1 - (1 - confidenceLevel) / 2); |
| if (!(probability in tDistributionInverseCDF)) { |
| console.warn('We only support ' + this.supportedConfidenceLevels().map( |
| @@ -77,20 +76,31 @@ var Statistics = new (function () { |
| return Number.POSITIVE_INFINITY; |
| var cdfForProbability = tDistributionInverseCDF[probability]; |
| - var degreesOfFreedom = numberOfSamples - 1; |
| + var degreesOfFreedom = opt_degreeOfFreedom || numberOfSamples - 1; |
|
petrcermak
2015/09/10 09:04:09
In theory (and most probably in practice as well),
nednguyen
2015/09/10 15:11:59
Done. I picked the first one.
|
| // 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 quantile * this.sampleStandardDeviation(numberOfSamples, sum, squareSum) / Math.sqrt(numberOfSamples); |
| + 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) { |
| + var sampleStandardDeviation = this.sampleStandardDeviation(numberOfSamples, sum, squareSum); |
| + return this.confidenceIntervalDeltaFromStd(confidenceLevel, numberOfSamples, sampleStandardDeviation); |
| + } |
| + |
| + this.confidenceIntervalDeltaFromStd = function (confidenceLevel, numberOfSamples, sampleStandardDeviation, opt_degreeOfFreedom) { |
| + var quantile = this.quantile(confidenceLevel, numberOfSamples, opt_degreeOfFreedom); |
| + return quantile * sampleStandardDeviation / Math.sqrt(numberOfSamples); |
| + } |
| + |
| + |
| this.confidenceInterval = function (values, probability) { |
| var sum = this.sum(values); |
| var mean = sum / values.length; |