MCPcopy Create free account
hub / github.com/MIT-SPARK/Clio / TEST

Function TEST

clio/tests/test_probability_utilities.cpp:13–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13TEST(ProbabilityUtilities, TestShannonEntropy) {
14 const auto fmt = getDefaultFormat();
15 { // test case 1: no entropy
16 Eigen::VectorXd p = getBinaryProbability(0.0);
17 EXPECT_NEAR(shannonEntropy(p), 0.0, 1.0e-9) << "input: " << p.format(fmt);
18 }
19
20 { // test case 2: also no entropy
21 Eigen::VectorXd p = getBinaryProbability(1.0);
22 EXPECT_NEAR(shannonEntropy(p), 0.0, 1.0e-9) << "input: " << p.format(fmt);
23 }
24
25 { // test case 3: max entropy (of 1 bit)
26 Eigen::VectorXd p = getBinaryProbability(0.5);
27 EXPECT_NEAR(shannonEntropy(p), 1.0, 1.0e-9) << "input: " << p.format(fmt);
28 }
29}
30
31TEST(ProbabilityUtilities, TestJSDivergence) {
32 { // test case 1: complete divergence

Callers

nothing calls this directly

Calls 4

getBinaryProbabilityFunction · 0.85
shannonEntropyFunction · 0.85
jensenShannonDivergenceFunction · 0.85
mutualInformationFunction · 0.85

Tested by

no test coverage detected