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

Method another_test

dlib/test/statistics.cpp:650–700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

648 }
649
650 void another_test()
651 {
652 std::vector<double> a;
653
654 running_stats<double> rs1, rs2;
655
656 for (int i = 0; i < 10; ++i)
657 {
658 rs1.add(i);
659 a.push_back(i);
660 }
661
662 DLIB_TEST(std::abs(variance(mat(a)) - rs1.variance()) < 1e-13);
663 DLIB_TEST(std::abs(stddev(mat(a)) - rs1.stddev()) < 1e-13);
664 DLIB_TEST(std::abs(mean(mat(a)) - rs1.mean()) < 1e-13);
665
666 for (int i = 10; i < 20; ++i)
667 {
668 rs2.add(i);
669 a.push_back(i);
670 }
671
672 DLIB_TEST(std::abs(variance(mat(a)) - (rs1+rs2).variance()) < 1e-13);
673 DLIB_TEST(std::abs(mean(mat(a)) - (rs1+rs2).mean()) < 1e-13);
674 DLIB_TEST((rs1+rs2).current_n() == 20);
675
676 running_scalar_covariance<double> rc1, rc2, rc3;
677 dlib::rand rnd;
678 for (double i = 0; i < 10; ++i)
679 {
680 const double a = i + rnd.get_random_gaussian();
681 const double b = i + rnd.get_random_gaussian();
682 rc1.add(a,b);
683 rc3.add(a,b);
684 }
685 for (double i = 11; i < 20; ++i)
686 {
687 const double a = i + rnd.get_random_gaussian();
688 const double b = i + rnd.get_random_gaussian();
689 rc2.add(a,b);
690 rc3.add(a,b);
691 }
692
693 DLIB_TEST(std::abs((rc1+rc2).mean_x() - rc3.mean_x()) < 1e-13);
694 DLIB_TEST(std::abs((rc1+rc2).mean_y() - rc3.mean_y()) < 1e-13);
695 DLIB_TEST_MSG(std::abs((rc1+rc2).variance_x() - rc3.variance_x()) < 1e-13, std::abs((rc1+rc2).variance_x() - rc3.variance_x()));
696 DLIB_TEST(std::abs((rc1+rc2).variance_y() - rc3.variance_y()) < 1e-13);
697 DLIB_TEST(std::abs((rc1+rc2).covariance() - rc3.covariance()) < 1e-13);
698 DLIB_TEST((rc1+rc2).current_n() == rc3.current_n());
699
700 }
701
702 void test_average_precision()
703 {

Callers

nothing calls this directly

Calls 15

absFunction · 0.85
varianceFunction · 0.85
stddevFunction · 0.85
meanFunction · 0.85
get_random_gaussianMethod · 0.80
matFunction · 0.50
addMethod · 0.45
push_backMethod · 0.45
varianceMethod · 0.45
stddevMethod · 0.45
meanMethod · 0.45
current_nMethod · 0.45

Tested by

no test coverage detected