| 976 | } |
| 977 | |
| 978 | void test_running_stats_decayed() |
| 979 | { |
| 980 | print_spinner(); |
| 981 | std::vector<double> tmp(300); |
| 982 | std::vector<double> tmp_var(tmp.size()); |
| 983 | dlib::rand rnd; |
| 984 | const int num_rounds = 100000; |
| 985 | for (int rounds = 0; rounds < num_rounds; ++rounds) |
| 986 | { |
| 987 | running_stats_decayed<double> rs(100); |
| 988 | |
| 989 | for (size_t i = 0; i < tmp.size(); ++i) |
| 990 | { |
| 991 | rs.add(rnd.get_random_gaussian() + 1); |
| 992 | tmp[i] += rs.mean(); |
| 993 | if (i > 0) |
| 994 | tmp_var[i] += rs.variance(); |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | // should print all 1s basically since the mean and variance should always be 1. |
| 999 | for (size_t i = 0; i < tmp.size(); ++i) |
| 1000 | { |
| 1001 | DLIB_TEST(std::abs(1-tmp[i]/num_rounds) < 0.001); |
| 1002 | if (i > 1) |
| 1003 | DLIB_TEST(std::abs(1-tmp_var[i]/num_rounds) < 0.01); |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | void test_running_scalar_covariance_decayed() |
| 1008 | { |
nothing calls this directly
no test coverage detected