def test_Integate_Mean(self): a = smctc.sampler(10, smctc.HistoryType.SMC_HISTORY_NONE) a.SetResampleParams(smctc.ResampleType.SMC_RESAMPLE_RESIDUAL, 0.5) fmove = smctc.moveset(fInitialise, fMove) a.SetMoveSet(fmove) a.Initialise() a.Integrate_Mean(0)
return smctc.particle(value,logLikelihood(0,value)) def fMove(lTime, pFrom, pRng): """ The proposal function. param: lTime[int] The sampler iteration. param: pFrom[smc.particle] The particle to move. param: pRng[smc.rng] A random number generator. """ cv_to = pFrom.GetValue() # cv_state, list cv_to[0] += cv_to[2] * Delta + pRng.Normal(0,sqrt(var_s)) cv_to[2] += pRng.Normal(0,sqrt(var_u)) cv_to[1] += cv_to[3] * Delta + pRng.Normal(0,sqrt(var_s)) cv_to[3] += pRng.Normal(0,sqrt(var_u)) pFrom.AddToLogWeight(logLikelihood(lTime, cv_to)) if __name__ == '__main__': load_observation() fmove = smctc.moveset(fInitialise, fMove) a=smctc.sampler(1000,smctc.HistoryType.SMC_HISTORY_NONE) a.SetResampleParams(smctc.ResampleType.SMC_RESAMPLE_RESIDUAL,0.5) a.SetMoveSet(fmove) a.Initialise() for i in range(len(y)-1): a.Iterate() xm = a.Integrate_Mean(0) ym = a.Integrate_Mean(1) print(xm, ym)
def test_Init(self): smctc.sampler(100, smctc.HistoryType.SMC_HISTORY_NONE)