///\param lTime The sampler iteration. ///\param pFrom The particle to move. ///\param pRng A random number generator. void fMove(long lTime, smc::particle<State> & pFrom, smc::rng *pRng) { State *to = pFrom.GetValuePointer(); int lineFieldAtPrevTime = to->lineField[0]; // probability of a value which lineField0 takes is proportional to exp(-beta*KronekkerDelta(lineField0 + lineField1, 2)) double normalizationConstant, probOfNoEdge; if(lineFieldAtPrevTime == 0){ // no edge at previous time normalizationConstant = 1 + 1; } else { normalizationConstant = 1 + exp(-to->beta); } probOfNoEdge = 1 / normalizationConstant; // transition to->lineField[1] = to->lineField[0]; if(pRng->UniformS() < probOfNoEdge){ to->lineField[0] = 0; } else { to->lineField[0] = 1; } to->alpha += pRng->Normal(0, alpha0 / 100.0); to->beta += pRng->Normal(0, beta0 / 100.0); to->gamma += pRng->Normal(0, gamma0 / 100.0); pFrom.AddToLogWeight(logLikelihood(lTime, *to)); }
///\param lTime The sampler iteration. ///\param pFrom The particle to move. ///\param pRng A random number generator. void fMove(long lTime, smc::particle<double> & pFrom, smc::rng *pRng) { double *to = pFrom.GetValuePointer(); double x = 0.5 * (*to) + 25.0*(*to) / (1.0 + (*to) * (*to)) + 8.0 * cos(1.2 * ( lTime)) + pRng->Normal(0.0,std_x); *to = x; pFrom.AddToLogWeight(logLikelihood(lTime, *to)); }