Commit 724b9941 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Added option for kitagawa/stratified approach in traditional resampling.

parent 3b471e3a
...@@ -178,9 +178,10 @@ particle.unscented.alpha = 1 ; ...@@ -178,9 +178,10 @@ particle.unscented.alpha = 1 ;
particle.unscented.beta = 2 ; particle.unscented.beta = 2 ;
particle.unscented.kappa = 1 ; particle.unscented.kappa = 1 ;
% Configuration of resampling in case of particles % Configuration of resampling in case of particles
particle.resampling = 'systematic' ; particle.resampling.status = 'systematic' ;
% Choice of the resampling method % Choice of the resampling method
particle.resampling_method = 'traditional' ; particle.resampling.method1 = 'traditional' ;
particle.resampling.method2 = 'kitagawa';
% Configuration of the mixture filters % Configuration of the mixture filters
particle.mixture_method = 'particles' ; particle.mixture_method = 'particles' ;
% Size of the different mixtures % Size of the different mixtures
......
function indx = resample(weights,method) function indx = resample(weights,method1,method2)
% Resamples particles. % Resamples particles.
%@info: %@info:
...@@ -54,11 +54,17 @@ function indx = resample(weights,method) ...@@ -54,11 +54,17 @@ function indx = resample(weights,method)
% AUTHOR(S) frederic DOT karame AT univ DASH evry DOT fr % AUTHOR(S) frederic DOT karame AT univ DASH evry DOT fr
% stephane DOT adjemian AT univ DASH lemans DOT fr % stephane DOT adjemian AT univ DASH lemans DOT fr
switch method switch method1
case 'residual' case 'residual'
indx = residual_resampling(weights); indx = residual_resampling(weights);
case 'traditional' case 'traditional'
indx = traditional_resampling(weights); if strcmpi(method2,'kitagawa')
indx = traditional_resampling(weights,rand);
elseif strcmpi(method2,'stratified')
indx = traditional_resampling(weights,rand(size(weights)));
else
error('particle::resample: Unknown method!')
end
otherwise otherwise
error('particle::resample: Unknown method!') error('particle::resample: Unknown method!')
end end
\ No newline at end of file
...@@ -132,11 +132,11 @@ for t=1:sample_size ...@@ -132,11 +132,11 @@ for t=1:sample_size
lik(t) = log(mean(wtilde))+dfac; lik(t) = log(mean(wtilde))+dfac;
weights = wtilde/sum(wtilde); weights = wtilde/sum(wtilde);
Neff = 1/(weights*weights'); Neff = 1/(weights*weights');
if (Neff<.5*sample_size && ~isempty(strmatch(DynareOptions.particle.resampling,'generic','exact'))) || ~isempty(strmatch(DynareOptions.particle.resampling,'systematic','exact')) if (Neff<.5*sample_size && strcmpi(DynareOptions.particle.resampling.status,'generic')) || strcmpi(DynareOptions.particle.resampling.status,'systematic')
nb_obs_resamp = nb_obs_resamp+1 ; nb_obs_resamp = nb_obs_resamp+1 ;
StateVectors = tmp(mf0,resample(weights,DynareOptions.particle.resampling_method)); StateVectors = tmp(mf0,resample(weights,DynareOptions.particle.resampling.method1,DynareOptions.particle.resampling.method2));
weights = ones(1,number_of_particles) ; weights = ones(1,number_of_particles) ;
elseif ~isempty(strmatch(DynareOptions.particle_filter.resampling,'none','exact')) elseif strcmpi(DynareOptions.particle_filter.resampling.status,'none')
StateVectors = tmp(mf0,:); StateVectors = tmp(mf0,:);
weights = number_of_particles*weights; weights = number_of_particles*weights;
end end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment