Skip to content

epymorph.parameter_fitting.filter.particle_filter

ParticleFilter

ParticleFilter(
    num_particles: int,
    resampler: Type[WeightsResampling] = WeightsResampling,
)

Bases: BaseFilter

A class to run the particle filter for estimating parameters.

Attributes:

Parameters:

num_particles instance-attribute

num_particles = num_particles

param_quantiles instance-attribute

param_quantiles = {}

param_values instance-attribute

param_values = {}

resampler instance-attribute

resampler = resampler

propagate_particles

propagate_particles(
    particles: List[Particle],
    rume: RUME,
    simulation: EpymorphSimulation,
    date: str,
    duration: int,
    model_link: ModelLink,
    params_space: Dict[str, EstimateParameters],
    rng: Generator,
) -> Tuple[List[Particle], List[ndarray]]

Propagates particles through the simulation model.

Parameters:

  • particles (List[Particle]) –

    The particles which represent the current estimate of the filter.

  • rume (Rume) –

    Model parameters including population size and geographical information.

  • simulation (EpymorphSimulation) –

    The object which propagates the particles.

  • date (str) –

    Current date.

  • duration (int) –

    Duration of propagation in days.

  • model_link (ModelLink) –

    Information used to match the model output with the observations.

  • params_space (Dict[str, EstimateParameters]) –

    The parameters to be estimated and the methods used to estimate them.

Returns:

  • Tuple
    • A list of propagated Particle objects with updated observations.
    • A list of expected observations for each particle after propagation.

run

run(
    rume: RUME,
    likelihood_fn: Likelihood,
    params_space: Dict[str, EstimateParameters],
    model_link: ModelLink,
    dates: Any,
    cases: List[ndarray],
    rng: Generator,
) -> ParticleFilterOutput

Runs the particle filter to estimate parameters.

Parameters:

  • rume (Rume) –

    Model parameters, including population size and geographical information.

  • likelihood_fn (Likelihood) –

    The likelihood function to use in the resampling.

  • params_space (Dict[str, EstimateParameters]) –

    The parameters to estimate and the methods to estimate them.

  • model_link (ModelLink) –

    Link to the model used for simulations.

  • index (int) –

    Index of the parameter to estimate.

  • dates (Any) –

    Dates for which observations are available.

  • cases (List[int]) –

    Observed case data over time.

Returns:

  • ParticleFilterOutput

    The result of the particle filter containing parameter estimates, quantiles, and model data.