indii/ml/aux/RandomPartitioner.cpp

00001 #include "RandomPartitioner.hpp"
00002 
00003 using namespace indii::ml::aux;
00004 
00005 RandomPartitioner::~RandomPartitioner() {
00006   //
00007 }
00008 
00009 bool RandomPartitioner::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 lower, upper, x;
00016 
00017   /* randomly select dimension */
00018   index = static_cast<unsigned int>(Random::uniform(0, p->getDimensions()));
00019 
00020   /* split on midpoint of selected dimension */
00021   lower = p->get(is[0])(index);
00022   upper = lower;
00023   for (i = 1; i < is.size(); i++) {
00024     x = p->get(is[i])(index);
00025     if (x < lower) {
00026       lower = x;
00027     } else if (x > upper) {
00028       upper = x;
00029     }
00030   }
00031   this->value = (lower + upper) / 2.0;
00032   
00033   return (upper - lower > 0.0);
00034 }
00035 

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