| 208 | |
| 209 | template <typename rand_type> |
| 210 | void test_normal_numbers( |
| 211 | rand_type& rnd |
| 212 | ) |
| 213 | { |
| 214 | print_spinner(); |
| 215 | dlog << LINFO << "test normality"; |
| 216 | double cnt1 = 0; // num <= -1.2 |
| 217 | double cnt2 = 0; // num <= -0.5 |
| 218 | double cnt3 = 0; // num <= 0 |
| 219 | double cnt4 = 0; // num <= 0.5 |
| 220 | double cnt5 = 0; // num <= 1.2 |
| 221 | |
| 222 | const unsigned long total = 1000000; |
| 223 | for (unsigned long i = 0; i < total; ++i) |
| 224 | { |
| 225 | const double r = rnd.get_random_gaussian(); |
| 226 | if (r <= -1.2) cnt1 += 1; |
| 227 | if (r <= -0.5) cnt2 += 1; |
| 228 | if (r <= 0) cnt3 += 1; |
| 229 | if (r <= 0.5) cnt4 += 1; |
| 230 | if (r <= 1.2) cnt5 += 1; |
| 231 | } |
| 232 | |
| 233 | cnt1 /= total; |
| 234 | cnt2 /= total; |
| 235 | cnt3 /= total; |
| 236 | cnt4 /= total; |
| 237 | cnt5 /= total; |
| 238 | |
| 239 | dlog << LINFO << "cnt1: "<< cnt1; |
| 240 | dlog << LINFO << "cnt2: "<< cnt2; |
| 241 | dlog << LINFO << "cnt3: "<< cnt3; |
| 242 | dlog << LINFO << "cnt4: "<< cnt4; |
| 243 | dlog << LINFO << "cnt5: "<< cnt5; |
| 244 | |
| 245 | DLIB_TEST(std::abs(cnt1 - 0.11507) < 0.001); |
| 246 | DLIB_TEST(std::abs(cnt2 - 0.30854) < 0.001); |
| 247 | DLIB_TEST(std::abs(cnt3 - 0.5) < 0.001); |
| 248 | DLIB_TEST(std::abs(cnt4 - 0.69146) < 0.001); |
| 249 | DLIB_TEST(std::abs(cnt5 - 0.88493) < 0.001); |
| 250 | |
| 251 | } |
| 252 | |
| 253 | void test_gaussian_random_hash() |
| 254 | { |
no test coverage detected