# Particle filter correct function and likelihood as an output

4 visualizaciones (últimos 30 días)
zym el 4 de Sept. de 2022
Comentada: zym el 7 de Sept. de 2022
Hi, I am wondering if there is an easy way to extract the likelihood for each particle using the correct function. At the moment the correct function just calculates the likelihood to get weights for the resampling. To avoid double re-calculation, could correct function retrieve also the likelihood? I need this for the computation of likelihood using mle. I believe it is a nice addition to the function.
Regards!
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Remo Pillat el 6 de Sept. de 2022
Hi zym,
Unfortunately, there is no way of retrieving the individual particle likelihoods from the correct function.
As a workaround, you can retrieve the likelihood by evaluating the MeasurementLikelihoodFcn after the prediction step. This incurs a little extra overhead, but if your MeasurementLikelihoodFcn is simple, this might be acceptable for your application. See a small example here of evaluating the function between the prediction and correction steps and calculating the likelihood vector:
% Create a particle filter
pf = stateEstimatorPF;
% Initialize the particle filter at state [4 1 9] with unit covariance
initialize(pf, 5000, [4 1 9], eye(3), 'StateOrientation', 'row');
% Run one predict step
statePredicted = predict(pf);
% Assume we have a measurement [4.2 0.9 9]
% (Optional) calculate likelihood for each particle.
measurement = [4.2 0.9 9];
likelihood = feval(pf.MeasurementLikelihoodFcn, pf, pf.Particles, measurement)
likelihood = 5000×1
0.0042 0.0025 0.0032 0.0220 0.0533 0.0053 0.0000 0.0751 0.0034 0.0129
% Run correct step with measurement
stateCorrected = correct(pf, measurement);
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
zym el 7 de Sept. de 2022
Thanks a lot for your answer! It would be very useful to incorporate this possibility in future releases.

Iniciar sesión para comentar.

### Categorías

Más información sobre Mapping and Localization en Help Center y File Exchange.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by