24 #ifndef _CONDENSATION_GENERAL_HH_
25 #define _CONDENSATION_GENERAL_HH_
26 #include <Base/Common/BIASpragmaStart.hh>
29 #include "Base/Debug/Debug.hh"
30 #include "Base/Math/Random.hh"
31 #include "Base/Math/Vector.hh"
35 #include "Base/Debug/TimeMeasure.hh"
91 int Init(
unsigned int nrSmaples);
100 int PredictNewSamplePositions();
106 inline const std::vector<BIAS::Vector<double> >&
119 double GetVariance()
const;
136 double GetMeanWeight()
const;
142 void SetDefaultInitFraction(
double fraction);
146 void SetImportanceSampleFraction(
double fraction);
153 { processMean_=newProcessMean; }
157 virtual void InitModelDefaults() = 0;
163 virtual void InitPriorPositions(
unsigned int nrOfInitSamples) = 0;
169 virtual void EvaluateObservationDensities()=0;
180 bool _doSecondOrderARP;
183 inline void SecondOrderARP_(
unsigned int indexOldSample,
200 inline unsigned int PickOneSample_();
203 inline unsigned int PickImportanceSample_();
211 virtual void CalculateBaseWeights_();
215 virtual void AddDiffusions_();
219 virtual void AddOffsets_();
221 inline void CalculateMean_();
253 {
return (*((
double*)l))>(*((
double*)r)); }
265 register unsigned int low, middle, high;
270 while (high>(low+1)) {
271 middle = (high+low) >> 1;
286 unsigned int low, middle, high;
291 while (high>(low+1)) {
292 middle = (high+low)/2;
308 BCDOUT(D_COND_DEBUG,
"in SOARP d: "<<d<<std::endl);
339 std::cerr <<
"Condensation::CalculateMean_() took "<<timer.
GetRealTime()<<
" us"<<std::endl;
345 #include <Base/Common/BIASpragmaEnd.hh>
virtual void EvaluateImportanceWeights()
If you want to use importance sampling, then overload this function, which is the importance function...
BIAS::Vector< double > offSet_
unsigned int PickImportanceSample_()
CONDENSATION (CONditional DENSity EstimATION) is a state estimator very similiar to the Kalman Filter...
std::vector< double > sampleWeights_
Vector< double > processFirstOrderScale_
void SetPredictionOffset(const BIAS::Vector< double > &offSet)
all samples are moved by this offset at the prediction step
std::vector< Vector< double > > samplePosNew_
Vector< double > meanTminus1_
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
std::vector< unsigned int > oldIndices_
Vector< double > GetMean()
returns the mean state of the density distribution
Vector< double > processMean_
Vector< double > processSecondOrderScale_
double sumOfImportanceWeights_
double importanceFraction_
double defaultInitFraction_
std::vector< double > correctionOfImportanceWeights_
void SetProcessMean(const BIAS::Vector< double > &newProcessMean)
set a new processMean for the PredictSamplePosition step, see SecondOrderARP_()
void Set(const T &scalar)
void SecondOrderARP_(unsigned int indexOldSample, Vector< double > &newSample)
question: real pos_tminus2 of each sample or better old mean value for all samples?
double GetRealTime() const
return real time (=wall time clock) in usec JW For Win32: real-time is measured differently from user...
static int compdouble(const void *l, const void *r)
std::vector< double > sampleImportanceWeights_
std::vector< Vector< double > > samplePosOld_
std::vector< unsigned int > indexTminus2_
std::vector< Vector< double > > samplePosTminus2_
std::vector< double > cumulProbArray_
const std::vector< BIAS::Vector< double > > & GetSamplePositions()
class for producing random numbers from different distributions
class TimeMeasure contains functions for timing real time and cpu time.
unsigned int PickOneSample_()
The process model for a first-order auto-regressive process is: x_{t+1} - mean = (x_t - mean)*scalin...
void MultiplyIP(const T &scalar)
in place multiplication with scalar
std::vector< double > cumulProbArrayImportance_