indii/ml/aux/VariancePartitioner.cpp

00001 #include "VariancePartitioner.hpp"
00002 
00003 using namespace indii::ml::aux;
00004 
00005 VariancePartitioner::~VariancePartitioner() {
00006   //
00007 }
00008 
00009 bool VariancePartitioner::init(DiracMixturePdf* p,
00010       const std::vector<unsigned int>& is) {
00011   /* pre-condition */
00012   assert (is.size() >= 2);
00013     
00014   unsigned int i;
00015   double W = p->getTotalWeight();
00016   vector& first = p->get(is[0]);
00017   double w = p->getWeight(is[0]);
00018 
00019   vector mu(w * first);
00020   vector sigma(w * element_prod(first, first));
00021 
00022   for (i = 1; i < is.size(); i++) {
00023     vector& x(p->get(is[i]));
00024     w = p->getWeight(is[i]);
00025     
00026     noalias(mu) += w * x;
00027     noalias(sigma) += w * element_prod(x,x);
00028   }
00029 
00030   noalias(sigma) -= element_prod(mu, mu);
00031   mu /= W;
00032   sigma /= W;
00033 
00034   /* select dimension of highest variance */
00035   this->index = index_norm_inf(sigma);
00036   
00037   /* split on mean of given dimension */
00038   this->value = mu(index);
00039   
00040   return sigma(this->index) > 0.0;
00041 }
00042 

Generated on Wed Dec 17 15:11:57 2008 for dysii Dynamical Systems Library by  doxygen 1.5.3