indii/ml/aux/VariancePartitioner.hpp

00001 #ifndef INDII_ML_AUX_VARIANCEPARTITIONER_HPP
00002 #define INDII_ML_AUX_VARIANCEPARTITIONER_HPP
00003 
00004 #include "Partitioner.hpp"
00005 
00006 namespace indii {
00007   namespace ml {
00008     namespace aux {
00009 /**
00010  * Partitions a set of weighted points into two sets at the mean of the
00011  * dimension with greatest variance.
00012  *
00013  * @author Lawrence Murray <lawrence@indii.org>
00014  * @version $Rev: 477 $
00015  * @date $Date: 2008-07-24 23:39:18 +0100 (Thu, 24 Jul 2008) $
00016  *
00017  * @bug Points with negligible but nonzero weight may not be able to be 
00018  * split off from others using the mean. Consider two points, one with
00019  * negligible weight, the other which consequently equals the mean. Both
00020  * points may therefore lie on the same side of the split.
00021  */
00022 class VariancePartitioner : public Partitioner {
00023 public:
00024   /**
00025    * Destructor.
00026    */
00027   virtual ~VariancePartitioner();
00028 
00029   virtual bool init(DiracMixturePdf* p,
00030       const std::vector<unsigned int>& is);
00031   
00032   virtual Partitioner::Partition assign(const vector& x);
00033 
00034 private:
00035   /**
00036    * Index of the dimension on which to split.
00037    */
00038   unsigned int index;
00039   
00040   /**
00041    * Value along which to split.
00042    */
00043   double value;
00044 
00045 };
00046  
00047     }
00048   }
00049 }
00050 
00051 inline indii::ml::aux::Partitioner::Partition
00052     indii::ml::aux::VariancePartitioner::assign(const aux::vector& x) {
00053   /* pre-condition */
00054   assert (x.size() > index);
00055 
00056   if (x(index) <= value) {
00057     return Partitioner::LEFT;
00058   } else {
00059     return Partitioner::RIGHT;
00060   }
00061 }
00062 
00063 #endif
00064 

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