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

Function test_weibull_distribution

dlib/test/rand.cpp:411–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409 }
410
411 void test_weibull_distribution()
412 {
413 print_spinner();
414 dlib::rand rnd(0);
415
416 const size_t N = 1024*1024*4;
417 const double tol = 0.01;
418 double k=1.0, lambda=2.0, g=6.0;
419
420 dlib::running_stats<double> stats;
421 for (size_t i = 0; i < N; i++)
422 stats.add(rnd.get_random_weibull(lambda, k, g));
423
424 double expected_mean = g + lambda*std::tgamma(1 + 1.0 / k);
425 double expected_var = lambda*lambda*(std::tgamma(1 + 2.0 / k) - std::pow(std::tgamma(1 + 1.0 / k),2));
426 DLIB_TEST(std::abs(stats.mean() - expected_mean) < tol);
427 DLIB_TEST(std::abs(stats.variance() - expected_var) < tol);
428 }
429
430 void test_exponential_distribution()
431 {

Callers 1

perform_testMethod · 0.85

Calls 6

print_spinnerFunction · 0.85
absFunction · 0.85
get_random_weibullMethod · 0.80
addMethod · 0.45
meanMethod · 0.45
varianceMethod · 0.45

Tested by

no test coverage detected