Fixed texinfo header. Added two internal tests.
parent
f9671be3d2
commit
8f95711445
|
@ -1,20 +1,17 @@
|
||||||
function indx = residual_resampling(weights)
|
function indx = residual_resampling(weights)
|
||||||
|
% Resamples particles.
|
||||||
|
|
||||||
%@info:
|
%@info:
|
||||||
%! @deftypefn {Function File} {@var{indx} =} resample (@var{weights},@var{noise})
|
%! @deftypefn {Function File} {@var{indx} =} residual_resampling (@var{weights})
|
||||||
%! @anchor{particle/traditional_resampling}
|
%! @anchor{particle/residual_resampling}
|
||||||
%! @sp 1
|
%! @sp 1
|
||||||
%! Resamples particles (Resampling à la Kitagawa or stratified resampling).
|
%! Resamples particles.
|
||||||
%!
|
|
||||||
%! @sp 2
|
%! @sp 2
|
||||||
%! @strong{Inputs}
|
%! @strong{Inputs}
|
||||||
%! @sp 1
|
%! @sp 1
|
||||||
%! @table @ @var
|
%! @table @ @var
|
||||||
%! @item weights
|
%! @item weights
|
||||||
%! n*1 vector of doubles, particles' weights.
|
%! n*1 vector of doubles, particles' weights.
|
||||||
%! @item noise
|
|
||||||
%! n*1 vector of doubles sampled from a [0,1] uniform distribution (stratified resampling) or scalar double
|
|
||||||
%! sampled from a [0,1] uniform distribution (Kitagawa resampling).
|
|
||||||
%! @end table
|
%! @end table
|
||||||
%! @sp 2
|
%! @sp 2
|
||||||
%! @strong{Outputs}
|
%! @strong{Outputs}
|
||||||
|
@ -25,14 +22,15 @@ function indx = residual_resampling(weights)
|
||||||
%! @end table
|
%! @end table
|
||||||
%! @sp 2
|
%! @sp 2
|
||||||
%! @strong{This function is called by:}
|
%! @strong{This function is called by:}
|
||||||
|
%! @sp 1
|
||||||
%! @ref{particle/resample}
|
%! @ref{particle/resample}
|
||||||
%! @sp 2
|
%! @sp 2
|
||||||
%! @strong{This function calls:}
|
%! @strong{This function calls:}
|
||||||
%!
|
%! @sp 2
|
||||||
%! @end deftypefn
|
%! @end deftypefn
|
||||||
%@eod:
|
%@eod:
|
||||||
|
|
||||||
% Copyright (C) 2011 Dynare Team
|
% Copyright (C) 2011, 2012 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -50,7 +48,7 @@ function indx = residual_resampling(weights)
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
% 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
|
||||||
|
|
||||||
% What is the number of particles?
|
% What is the number of particles?
|
||||||
number_of_particles = length(weights);
|
number_of_particles = length(weights);
|
||||||
|
@ -89,4 +87,36 @@ for i=1:number_of_particles
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
k = k + iWEIGHTS(i);
|
k = k + iWEIGHTS(i);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
%@test:1
|
||||||
|
%$ % Define the weights
|
||||||
|
%$ weights = randn(2000,1).^2;
|
||||||
|
%$ weights = weights/sum(weights);
|
||||||
|
%$ % Initialize t.
|
||||||
|
%$ t = ones(1,1);
|
||||||
|
%$
|
||||||
|
%$ try
|
||||||
|
%$ indx1 = residual_resampling(weights);
|
||||||
|
%$ catch
|
||||||
|
%$ t(1) = 0;
|
||||||
|
%$ end
|
||||||
|
%$
|
||||||
|
%$ T = all(t);
|
||||||
|
%@eof:1
|
||||||
|
|
||||||
|
%@test:2
|
||||||
|
%$ % Define the weights
|
||||||
|
%$ weights = exp(randn(2000,1));
|
||||||
|
%$ weights = weights/sum(weights);
|
||||||
|
%$ % Initialize t.
|
||||||
|
%$ t = ones(1,1);
|
||||||
|
%$
|
||||||
|
%$ try
|
||||||
|
%$ indx1 = residual_resampling(weights);
|
||||||
|
%$ catch
|
||||||
|
%$ t(1) = 0;
|
||||||
|
%$ end
|
||||||
|
%$
|
||||||
|
%$ T = all(t);
|
||||||
|
%@eof:2
|
Loading…
Reference in New Issue