OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 3 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license | 5 * Use of this source code is governed by a BSD-style license |
6 * that can be found in the LICENSE file in the root of the source | 6 * that can be found in the LICENSE file in the root of the source |
7 * tree. An additional intellectual property rights grant can be found | 7 * tree. An additional intellectual property rights grant can be found |
8 * in the file PATENTS. All contributing project authors may | 8 * in the file PATENTS. All contributing project authors may |
9 * be found in the AUTHORS file in the root of the source tree. | 9 * be found in the AUTHORS file in the root of the source tree. |
10 */ | 10 */ |
(...skipping 13 matching lines...) Expand all Loading... |
24 EXPECT_GT(test_estimator.std_deviation(), 0.f); | 24 EXPECT_GT(test_estimator.std_deviation(), 0.f); |
25 // Test Clear method | 25 // Test Clear method |
26 test_estimator.Clear(); | 26 test_estimator.Clear(); |
27 EXPECT_EQ(test_estimator.mean(), 0.f); | 27 EXPECT_EQ(test_estimator.mean(), 0.f); |
28 EXPECT_EQ(test_estimator.std_deviation(), 0.f); | 28 EXPECT_EQ(test_estimator.std_deviation(), 0.f); |
29 } | 29 } |
30 | 30 |
31 TEST(MeanVarianceEstimatorTests, InsertZeroes) { | 31 TEST(MeanVarianceEstimatorTests, InsertZeroes) { |
32 MeanVarianceEstimator test_estimator; | 32 MeanVarianceEstimator test_estimator; |
33 // Insert the same value many times. | 33 // Insert the same value many times. |
34 for (size_t i = 0; i < 10000; i++) { | 34 for (size_t i = 0; i < 20000; i++) { |
35 test_estimator.Update(0.f); | 35 test_estimator.Update(0.f); |
36 } | 36 } |
37 EXPECT_EQ(test_estimator.mean(), 0.f); | 37 EXPECT_EQ(test_estimator.mean(), 0.f); |
38 EXPECT_EQ(test_estimator.std_deviation(), 0.f); | 38 EXPECT_EQ(test_estimator.std_deviation(), 0.f); |
39 } | 39 } |
40 | 40 |
41 TEST(MeanVarianceEstimatorTests, ConstantValueTest) { | 41 TEST(MeanVarianceEstimatorTests, ConstantValueTest) { |
42 MeanVarianceEstimator test_estimator; | 42 MeanVarianceEstimator test_estimator; |
43 for (size_t i = 0; i < 10000; i++) { | 43 for (size_t i = 0; i < 20000; i++) { |
44 test_estimator.Update(3.f); | 44 test_estimator.Update(3.f); |
45 } | 45 } |
46 // The mean should be close to three, and the standard deviation should be | 46 // The mean should be close to three, and the standard deviation should be |
47 // close to zero. | 47 // close to zero. |
48 EXPECT_NEAR(3.0f, test_estimator.mean(), 0.01f); | 48 EXPECT_NEAR(3.0f, test_estimator.mean(), 0.01f); |
49 EXPECT_NEAR(0.0f, test_estimator.std_deviation(), 0.01f); | 49 EXPECT_NEAR(0.0f, test_estimator.std_deviation(), 0.01f); |
50 } | 50 } |
51 | 51 |
52 TEST(MeanVarianceEstimatorTests, AlternatingValueTest) { | 52 TEST(MeanVarianceEstimatorTests, AlternatingValueTest) { |
53 MeanVarianceEstimator test_estimator; | 53 MeanVarianceEstimator test_estimator; |
54 for (size_t i = 0; i < 10000; i++) { | 54 for (size_t i = 0; i < 20000; i++) { |
55 test_estimator.Update(1.f); | 55 test_estimator.Update(1.f); |
56 test_estimator.Update(-1.f); | 56 test_estimator.Update(-1.f); |
57 } | 57 } |
58 // The mean should be close to zero, and the standard deviation should be | 58 // The mean should be close to zero, and the standard deviation should be |
59 // close to one. | 59 // close to one. |
60 EXPECT_NEAR(0.0f, test_estimator.mean(), 0.01f); | 60 EXPECT_NEAR(0.0f, test_estimator.mean(), 0.01f); |
61 EXPECT_NEAR(1.0f, test_estimator.std_deviation(), 0.01f); | 61 EXPECT_NEAR(1.0f, test_estimator.std_deviation(), 0.01f); |
62 } | 62 } |
63 | 63 |
64 } // namespace webrtc | 64 } // namespace webrtc |
OLD | NEW |