| 311 | // ---------------------------------------------------------------------------------------- |
| 312 | |
| 313 | void generate_concentric_circles ( |
| 314 | std::vector<sample_type>& samples, |
| 315 | std::vector<double>& labels, |
| 316 | const int num |
| 317 | ) |
| 318 | { |
| 319 | sample_type m(2,1); |
| 320 | samples.clear(); |
| 321 | labels.clear(); |
| 322 | |
| 323 | dlib::rand rnd; |
| 324 | |
| 325 | // make some samples near the origin |
| 326 | double radius = 1.0; |
| 327 | for (long i = 0; i < num; ++i) |
| 328 | { |
| 329 | double sign = 1; |
| 330 | if (rnd.get_random_double() < 0.5) |
| 331 | sign = -1; |
| 332 | m(0) = 2*radius*rnd.get_random_double()-radius; |
| 333 | m(1) = sign*sqrt(radius*radius - m(0)*m(0)); |
| 334 | |
| 335 | samples.push_back(m); |
| 336 | labels.push_back(1); |
| 337 | } |
| 338 | |
| 339 | // make some samples in a circle around the origin but far away |
| 340 | radius = 5.0; |
| 341 | for (long i = 0; i < num; ++i) |
| 342 | { |
| 343 | double sign = 1; |
| 344 | if (rnd.get_random_double() < 0.5) |
| 345 | sign = -1; |
| 346 | m(0) = 2*radius*rnd.get_random_double()-radius; |
| 347 | m(1) = sign*sqrt(radius*radius - m(0)*m(0)); |
| 348 | |
| 349 | samples.push_back(m); |
| 350 | labels.push_back(2); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | // ---------------------------------------------------------------------------------------- |
| 355 |
no test coverage detected