1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
9 #include "base/strings/stringprintf.h"
10 #include "media/cast/test/utility/test_util.h"
16 MeanAndError::MeanAndError(const std::vector
<double>& values
) {
19 num_values
= values
.size();
21 for (size_t i
= 0; i
< num_values
; i
++) {
23 sqr_sum
+= values
[i
] * values
[i
];
25 mean
= sum
/ num_values
;
27 sqrt(std::max(0.0, num_values
* sqr_sum
- sum
* sum
)) / num_values
;
31 std::string
MeanAndError::AsString() const {
32 return base::StringPrintf("%f +/- %f", mean
, std_dev
);