00001 #ifndef INDII_ML_FILTER_ADDITIVENOISEPARTICLERESAMPLER_HPP 00002 #define INDII_ML_FILTER_ADDITIVENOISEPARTICLERESAMPLER_HPP 00003 00004 #include "ParticleResampler.hpp" 00005 #include "../aux/GaussianPdf.hpp" 00006 00007 namespace indii { 00008 namespace ml { 00009 namespace filter { 00010 /** 00011 * Particle resampler with independent additive noise source. 00012 * 00013 * @author Lawrence Murray <lawrence@indii.org> 00014 * @version $Rev: 520 $ 00015 * @date $Date: 2008-08-15 14:22:21 +0100 (Fri, 15 Aug 2008) $ 00016 * 00017 * @param P Type of independent resampling noise source. 00018 * 00019 * Produces a new approximation of a weighted sample set by adding 00020 * noise from an independent source. This would usually be used after 00021 * resampling with a weight-based resampler such as 00022 * StratifiedParticleResampler, a la Condensation @ref Isard1998 00023 * "(Isard & Blake 1998)". 00024 */ 00025 template <class P = indii::ml::aux::GaussianPdf> 00026 class AdditiveNoiseParticleResampler : public ParticleResampler { 00027 public: 00028 /** 00029 * Constructor. 00030 * 00031 * @param r Independent resampling noise source. 00032 */ 00033 AdditiveNoiseParticleResampler(const P& r); 00034 00035 /** 00036 * Destructor. 00037 */ 00038 virtual ~AdditiveNoiseParticleResampler(); 00039 00040 /** 00041 * Resample particle set. 00042 * 00043 * @param p Particle set to resample. 00044 * 00045 * The resampled particle set is constructed by taking each weighted 00046 * sample \f$(\mathbf{s}^{(i)},\pi^{(i)})\f$ of @p p and adding a 00047 * sample \f$\mathbf{r}^{(i)}\f$ from the independent reampling 00048 * noise source, giving 00049 * \f$(\mathbf{s}^{(i)}+\mathbf{r}^{(i)},\pi^{(i)})\f$. 00050 * 00051 * @return Resampled particle set. 00052 */ 00053 virtual indii::ml::aux::DiracMixturePdf resample( 00054 indii::ml::aux::DiracMixturePdf& p); 00055 00056 private: 00057 /** 00058 * Independent resampling noise source. 00059 */ 00060 P r; 00061 00062 }; 00063 00064 } 00065 } 00066 } 00067 00068 template <class P> 00069 indii::ml::filter::AdditiveNoiseParticleResampler<P>::AdditiveNoiseParticleResampler( 00070 const P& r) : r(r) { 00071 // 00072 } 00073 00074 template <class P> 00075 indii::ml::filter::AdditiveNoiseParticleResampler<P>::~AdditiveNoiseParticleResampler() { 00076 // 00077 } 00078 00079 template <class P> 00080 indii::ml::aux::DiracMixturePdf 00081 indii::ml::filter::AdditiveNoiseParticleResampler<P>::resample( 00082 indii::ml::aux::DiracMixturePdf& p) { 00083 indii::ml::aux::DiracMixturePdf q(p.getDimensions()); 00084 00085 const unsigned int P_local = p.getNumComponents(); 00086 unsigned int i; 00087 00088 for (i = 0; i < P_local; i++) { 00089 q.addComponent(aux::DiracPdf(p.getComponent(i) + r.sample()), 00090 p.getWeight()); 00091 } 00092 00093 return q; 00094 } 00095 00096 #endif 00097
1.5.3