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

Method test_random_subset_selector2

dlib/test/statistics.cpp:100–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98 }
99
100 void test_random_subset_selector2 ()
101 {
102 random_subset_selector<double> rand_set;
103 DLIB_TEST(rand_set.next_add_accepts() == false);
104 DLIB_TEST(rand_set.size() == 0);
105 DLIB_TEST(rand_set.max_size() == 0);
106
107 for (int j = 0; j < 30; ++j)
108 {
109 print_spinner();
110
111 running_stats<double> rs, rs2;
112
113 rand_set.set_max_size(1000);
114 DLIB_TEST(rand_set.next_add_accepts() == true);
115
116 for (double i = 0; i < 100000; ++i)
117 {
118 rs.add(i);
119 if (rand_set.next_add_accepts())
120 rand_set.add(i);
121 else
122 rand_set.add();
123 }
124
125 DLIB_TEST(rand_set.size() == 1000);
126 DLIB_TEST(rand_set.max_size() == 1000);
127
128 for (unsigned long i = 0; i < rand_set.size(); ++i)
129 rs2.add(rand_set[i]);
130
131
132 dlog << LDEBUG << "true mean: " << rs.mean();
133 dlog << LDEBUG << "true sampled: " << rs2.mean();
134 double ratio = rs.mean()/rs2.mean();
135 DLIB_TEST_MSG(0.96 < ratio && ratio < 1.04, " ratio: " << ratio);
136 }
137 }
138
139 void test_running_cross_covariance ()
140 {

Callers

nothing calls this directly

Calls 7

print_spinnerFunction · 0.85
next_add_acceptsMethod · 0.80
set_max_sizeMethod · 0.80
sizeMethod · 0.45
max_sizeMethod · 0.45
addMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected