17 if (theComponents.empty()) {
19 <<
"MultiGaussianStateCombiner1D:: state container to collapse is empty";
27 if (theComponents.size()==1)
return firstState;
33 double measCovar1(0.);
34 double measCovar2(0.);
35 for ( VSC::const_iterator mixtureIter1 = theComponents.begin();
36 mixtureIter1 != theComponents.end(); mixtureIter1++ ) {
37 double weight = mixtureIter1->weight();
40 double mean1 = mixtureIter1->mean();
41 meanMean += weight * mean1;
42 measCovar1 += weight * mixtureIter1->variance();
44 for ( VSC::const_iterator mixtureIter2 = mixtureIter1+1;
45 mixtureIter2 != theComponents.end(); mixtureIter2++ ) {
46 double posDiff = mean1 - mixtureIter2->mean();
57 double covGen = posDiff*posDiff;
59 measCovar2 += weight * mixtureIter2->weight() * covGen;
64 if (weightSum<DBL_MIN){
65 std::cout <<
"MultiGaussianStateCombiner1D:: New state has total weight of 0."
72 meanMean /= weightSum;
73 measCovar1 *= (1./weightSum);
74 measCovar2 *= (1./weightSum/weightSum);
75 measCovar = measCovar1 + measCovar2;
std::vector< SingleGaussianState1D > VSC
const SingleState1dContainer & components() const
access to components
SingleGaussianState1D combine(const MultiGaussianState1D &theState) const