MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/contrib/boosted_trees/lib/utils/random_test.cc:23–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21namespace {
22
23TEST(RandomTest, Poisson) {
24 random::PhiloxRandom philox(77L);
25 random::SimplePhilox rng(&philox);
26 for (int trial = 0; trial < 10; ++trial) {
27 const int32 num_bootstrap = 10000;
28 double sum = 0;
29 double zeros = 0;
30 double ones = 0;
31 for (int i = 0; i < num_bootstrap; ++i) {
32 auto n = PoissonBootstrap(&rng);
33 sum += n;
34 zeros += (n == 0) ? 1 : 0;
35 ones += (n == 1) ? 1 : 0;
36 }
37
38 // Ensure mean is near expected value.
39 const double expected_mean = 1.0; // lambda
40 const double mean_std_error = 1.0 / sqrt(num_bootstrap);
41 double mean = sum / num_bootstrap;
42 EXPECT_NEAR(mean, expected_mean, 3 * mean_std_error);
43
44 // Ensure probability mass for values 0 and 1 are near expected value.
45 const double expected_p = 0.368;
46 const double proportion_std_error =
47 sqrt(expected_p * (1 - expected_p) / num_bootstrap);
48 EXPECT_NEAR(zeros / num_bootstrap, expected_p, 3 * proportion_std_error);
49 EXPECT_NEAR(ones / num_bootstrap, expected_p, 3 * proportion_std_error);
50 }
51}
52
53} // namespace
54} // namespace utils

Callers

nothing calls this directly

Calls 2

PoissonBootstrapFunction · 0.85
sqrtClass · 0.50

Tested by

no test coverage detected