Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
724b9941
Commit
724b9941
authored
Mar 03, 2012
by
Stéphane Adjemian
Browse files
Added option for kitagawa/stratified approach in traditional resampling.
parent
3b471e3a
Changes
3
Show whitespace changes
Inline
Side-by-side
matlab/global_initialization.m
View file @
724b9941
...
...
@@ -178,9 +178,10 @@ particle.unscented.alpha = 1 ;
particle
.
unscented
.
beta
=
2
;
particle
.
unscented
.
kappa
=
1
;
% Configuration of resampling in case of particles
particle
.
resampling
=
'systematic'
;
particle
.
resampling
.
status
=
'systematic'
;
% Choice of the resampling method
particle
.
resampling_method
=
'traditional'
;
particle
.
resampling
.
method1
=
'traditional'
;
particle
.
resampling
.
method2
=
'kitagawa'
;
% Configuration of the mixture filters
particle
.
mixture_method
=
'particles'
;
% Size of the different mixtures
...
...
matlab/particle/resample.m
View file @
724b9941
function
indx
=
resample
(
weights
,
method
)
function
indx
=
resample
(
weights
,
method
1
,
method2
)
%
Resamples
particles
.
%
@info
:
...
...
@@ -54,11 +54,17 @@ function indx = resample(weights,method)
%
AUTHOR
(
S
)
frederic
DOT
karame
AT
univ
DASH
evry
DOT
fr
%
stephane
DOT
adjemian
AT
univ
DASH
lemans
DOT
fr
switch
method
switch
method
1
case
'
residual
'
indx
=
residual_resampling
(
weights
);
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
error
(
'
particle
::
resample
:
Unknown
method
!
'
)
end
\ No newline at end of file
matlab/particle/sequential_importance_particle_filter.m
View file @
724b9941
...
...
@@ -132,11 +132,11 @@ for t=1:sample_size
lik
(
t
)
=
log
(
mean
(
wtilde
))
+
dfac
;
weights
=
wtilde
/
sum
(
wtilde
);
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
;
StateVectors
=
tmp
(
mf0
,
resample
(
weights
,
DynareOptions
.
particle
.
resampling
_
method
));
StateVectors
=
tmp
(
mf0
,
resample
(
weights
,
DynareOptions
.
particle
.
resampling
.
method1
,
DynareOptions
.
particle
.
resampling
.
method
2
));
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
,
:
);
weights
=
number_of_particles
*
weights
;
end
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment