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
8f957114
Commit
8f957114
authored
Feb 22, 2012
by
Stéphane Adjemian
Browse files
Fixed texinfo header. Added two internal tests.
parent
f9671be3
Changes
1
Hide whitespace changes
Inline
Side-by-side
matlab/particle/residual_resampling.m
View file @
8f957114
function
indx
=
residual_resampling
(
weights
)
%
Resamples
particles
.
%
@info
:
%!
@deftypefn
{
Function
File
}
{
@var
{
indx
}
=
}
resampl
e
(
@var
{
weights
}
,
@var
{
noise
}
)
%!
@anchor
{
particle
/
tradition
al_resampling
}
%!
@deftypefn
{
Function
File
}
{
@var
{
indx
}
=
}
residual_
resampl
ing
(
@var
{
weights
})
%!
@anchor
{
particle
/
residu
al_resampling
}
%!
@sp
1
%!
Resamples
particles
(
Resampling
à
la
Kitagawa
or
stratified
resampling
).
%!
%!
Resamples
particles
.
%!
@sp
2
%!
@strong
{
Inputs
}
%!
@sp
1
%!
@table
@
@var
%!
@item
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
%!
@sp
2
%!
@strong
{
Outputs
}
...
...
@@ -25,14 +22,15 @@ function indx = residual_resampling(weights)
%!
@end
table
%!
@sp
2
%!
@strong
{
This
function
is
called
by
:
}
%!
@sp
1
%!
@ref
{
particle
/
resample
}
%!
@sp
2
%!
@strong
{
This
function
calls
:
}
%!
%!
@sp
2
%!
@end
deftypefn
%
@eod
:
%
Copyright
(
C
)
2011
Dynare
Team
%
Copyright
(
C
)
2011
,
2012
Dynare
Team
%
%
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/>.
%
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
?
number_of_particles
=
length
(
weights
);
...
...
@@ -89,4 +87,36 @@ for i=1:number_of_particles
end
end
k
=
k
+
iWEIGHTS
(
i
);
end
\ No newline at end of file
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
\ No newline at end of file
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