@@ -941,10 +941,10 @@ void CMultimodalPriorTest::testMarginalLikelihoodConfidenceInterval() {
941
941
942
942
using TMeanAccumulator = maths::CBasicStatistics::SSampleMean<double >::TAccumulator;
943
943
944
+ test::CRandomNumbers rng;
945
+
944
946
LOG_DEBUG (<< " Synthetic" );
945
947
{
946
- test::CRandomNumbers rng;
947
-
948
948
double w1 = 0.2 ;
949
949
double location1 = 0.1 ;
950
950
double squareScale1 = 0.2 ;
@@ -1047,6 +1047,33 @@ void CMultimodalPriorTest::testMarginalLikelihoodConfidenceInterval() {
1047
1047
CPPUNIT_ASSERT_DOUBLES_EQUAL (-111.0 , i90.first , 0.5 );
1048
1048
CPPUNIT_ASSERT_DOUBLES_EQUAL (158952.0 , i90.second , 0.5 );
1049
1049
}
1050
+
1051
+ LOG_DEBUG (<< " Non-unit count weight" );
1052
+ {
1053
+ // The confidence interval should be independent of the sample
1054
+ // count weight.
1055
+
1056
+ TDoubleVec modes[2 ];
1057
+ rng.generateNormalSamples (10.0 , 2.0 , 50 , modes[0 ]);
1058
+ rng.generateNormalSamples (20.0 , 2.0 , 50 , modes[1 ]);
1059
+ TDoubleVec samples (modes[0 ].begin (), modes[0 ].end ());
1060
+ samples.insert (samples.end (), modes[1 ].begin (), modes[1 ].end ());
1061
+
1062
+ CMultimodalPrior filter (makePrior ());
1063
+ filter.addSamples (samples);
1064
+
1065
+ CPPUNIT_ASSERT_EQUAL (std::size_t (2 ), filter.numberModes ());
1066
+
1067
+ TDoubleDoublePr interval{filter.marginalLikelihoodConfidenceInterval (
1068
+ 90.0 , maths_t::countWeight (1.0 ))};
1069
+ TDoubleDoublePr weightedInterval{filter.marginalLikelihoodConfidenceInterval (
1070
+ 90.0 , maths_t::countWeight (0.3 ))};
1071
+ LOG_DEBUG (<< " interval = " << core::CContainerPrinter::print (interval));
1072
+ LOG_DEBUG (<< " weightedInterval = "
1073
+ << core::CContainerPrinter::print (weightedInterval));
1074
+ CPPUNIT_ASSERT_EQUAL (core::CContainerPrinter::print (interval),
1075
+ core::CContainerPrinter::print (weightedInterval));
1076
+ }
1050
1077
}
1051
1078
1052
1079
void CMultimodalPriorTest::testSampleMarginalLikelihood () {
0 commit comments