12 if (theComponents.empty()) {
13 throw cms::Exception(
"LogicError") <<
"MultiGaussianStateCombiner1D:: state container to collapse is empty";
21 if (theComponents.size() == 1)
28 double measCovar1(0.);
29 double measCovar2(0.);
30 for (VSC::const_iterator mixtureIter1 = theComponents.begin(); mixtureIter1 != theComponents.end(); mixtureIter1++) {
31 double weight = mixtureIter1->weight();
34 double mean1 = mixtureIter1->mean();
35 meanMean +=
weight * mean1;
36 measCovar1 +=
weight * mixtureIter1->variance();
38 for (VSC::const_iterator mixtureIter2 = mixtureIter1 + 1; mixtureIter2 != theComponents.end(); mixtureIter2++) {
39 double posDiff = mean1 - mixtureIter2->mean();
50 double covGen = posDiff * posDiff;
52 measCovar2 +=
weight * mixtureIter2->weight() * covGen;
57 if (weightSum < DBL_MIN) {
58 std::cout <<
"MultiGaussianStateCombiner1D:: New state has total weight of 0." << std::endl;
64 weightSum = 1. / weightSum;
65 meanMean *= weightSum;
66 measCovar1 *= weightSum;
67 measCovar2 *= weightSum * weightSum;
68 measCovar = measCovar1 + measCovar2;