MCPcopy Create free account
hub / github.com/davisking/dlib / test_running_stats_decayed

Method test_running_stats_decayed

dlib/test/statistics.cpp:978–1005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 7

print_spinnerFunction · 0.85
absFunction · 0.85
get_random_gaussianMethod · 0.80
sizeMethod · 0.45
addMethod · 0.45
meanMethod · 0.45
varianceMethod · 0.45

Tested by

no test coverage detected