@@ -941,10 +941,10 @@ void CMultimodalPriorTest::testMarginalLikelihoodConfidenceInterval() {
941941
942942 using TMeanAccumulator = maths::CBasicStatistics::SSampleMean<double >::TAccumulator;
943943
944+ test::CRandomNumbers rng;
945+
944946 LOG_DEBUG (<< " Synthetic" );
945947 {
946- test::CRandomNumbers rng;
947-
948948 double w1 = 0.2 ;
949949 double location1 = 0.1 ;
950950 double squareScale1 = 0.2 ;
@@ -1047,6 +1047,33 @@ void CMultimodalPriorTest::testMarginalLikelihoodConfidenceInterval() {
10471047 CPPUNIT_ASSERT_DOUBLES_EQUAL (-111.0 , i90.first , 0.5 );
10481048 CPPUNIT_ASSERT_DOUBLES_EQUAL (158952.0 , i90.second , 0.5 );
10491049 }
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+ }
10501077}
10511078
10521079void CMultimodalPriorTest::testSampleMarginalLikelihood () {
0 commit comments