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:
-
num_particles
(int
) –Number of particles.
-
param_quantiles
(Dict[str, List[ndarray]]
) –Quantiles of parameters over time.
-
param_values
(Dict[str, List[ndarray]]
) –Mean values of parameters over time.
-
resampler
(Type[WeightsResampling]
) –The resampling method to use.
-
rng
(Generator
) –Random number generator for simulations and resampling.
Parameters:
-
num_particles
(int
) –Number of particles for the particle filter.
-
resampler
(Type[WeightsResampling]
, default:WeightsResampling
) –The resampler to use in the particle filter.
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.