6.13. pypfilt.pfilter

pypfilt.pfilter.run(ctx, start, end, obs_tables, history=None, save_when=None, save_to=None)

Run the particle filter against any number of data streams.

Parameters:
  • ctx (Context) – The simulation parameters.
  • start – The start of the simulation period.
  • end – The (exclusive) end of the simulation period.
  • obs_tables – A dictionary of observation tables.
  • history – The (optional) history matrix state from which to resume.
  • save_when – Times at which to save the particle history matrix.
  • save_to – The filename for saving the particle history matrix.
Returns:

The resulting simulation state: a dictionary that contains the simulation settings ('settings'), the particle history matrix ('history'), and the summary statistics ('summary').

pypfilt.pfilter.step(ctx, snapshot, step_num, step_obs, is_fs)

Perform a single time-step for every particle.

Parameters:
  • ctx (Context) – The simulation parameters.
  • snapshot (Snapshot) – The current particle states.
  • step_num – The time-step number.
  • step_obs – The list of observations for this time-step.
  • is_fs – Indicate whether this is a forecasting simulation (i.e., no observations). For deterministic models it is useful to add some random noise when estimating, to allow identical particles to differ in their behaviour, but this is not desirable when forecasting.
Returns:

True if resampling was performed, otherwise False.

pypfilt.pfilter.reweight(ctx, snapshot, obs)

Adjust particle weights in response to some observation(s).

Parameters:
  • ctx (Context) – The simulation parameters.
  • snapshot (Snapshot) – The current particle states.
  • obs – The observation(s) that have been made.
Returns:

A tuple; the first element (bool) indicates whether resampling is required, the second element (float) is the effective number of particles (i.e., accounting for weights).