epymorph.parameter_fitting.utils.resampler
WeightsResampling
WeightsResampling(N: int, likelihood_fn)
A class for computing and resampling weights in particle filtering.
Attributes:
-
N
(int
) –Number of particles.
-
static_params
(dict
) –Static parameters from the rume dictionary.
-
likelihood_fn
(object
) –An object responsible for computing the likelihood of observations.
Parameters:
-
N
(int
) –Number of particles.
-
likelihood_fn
(object
) –An object for computing the likelihood of observations.
compute_weights
Computes the weights for each particle based on the likelihood of the current observation.
Parameters:
-
current_obs_data
(ndarray
) –The current observation data.
-
expected_observations
(list
) –The expected observations corresponding to each particle.
Returns:
-
ndarray
–An array of computed weights normalized to sum to 1.
resample_particles
update_weights
ResamplingByNode
ResamplingByNode(N: int, likelihood_fn)
Bases: WeightsResampling
Uses an approximate resampling algorithm which is efficient for multi-node systems. The weights for each node are computed separately. During resampling the particles are decomposed by node, each node is resampled separately, and new particles are reconstructed treating nodes independently.
Attributes:
-
N
(int
) –Number of particles.
-
static_params
(dict
) –Static parameters from the rume dictionary.
-
likelihood_fn
(object
) –An object responsible for computing the likelihood of observations.
compute_weights
Computes the weights for each node for each particle based on the likelihood of the current observation.
Parameters:
-
current_obs_data
(ndarray
) –The current observation data.
-
expected_observations
(list
) –The expected observations corresponding to each particle.
Returns:
-
ndarray
–An array of computed weights with each row normalized to sum to 1.
resample_particles
Resamples particles using an approximate algorithm based on the computed weights. The particles are deconstructed by node, each node is resampled independently, then new particles are reconstructed.
Parameters:
-
particles
(list
) –Particles which represent the estimated state of the system.
-
weights
(ndarray
) –Wights corresponding to each node for each particle.
Returns:
-
list
–The resampled particles.