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
Tiago Peixoto
graph-tool
Commits
161d5214
Commit
161d5214
authored
Jan 02, 2020
by
Tiago Peixoto
Browse files
inference: fix split-merge bias in multiflip MCMC
parent
1cc4bfb1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph/inference/blockmodel/graph_blockmodel_multiflip_mcmc.hh
View file @
161d5214
...
...
@@ -468,52 +468,37 @@ struct MCMC
std
::
shuffle
(
vs
.
begin
(),
vs
.
end
(),
rng
);
double
lp
1
=
0
,
lp2
=
0
;
for
(
bool
swap
:
std
::
array
<
bool
,
2
>
({
false
,
true
})
)
double
lp
=
0
;
for
(
auto
v
:
vs
)
{
if
(
!
swap
)
push_b
(
vs
);
for
(
auto
v
:
vs
)
{
size_t
bv
=
_state
.
_b
[
v
];
size_t
nbv
=
(
bv
==
r
)
?
s
:
r
;
double
ddS
;
if
(
_state
.
virtual_remove_size
(
v
)
>
0
)
ddS
=
_state
.
virtual_move
(
v
,
bv
,
nbv
,
_entropy_args
);
else
ddS
=
std
::
numeric_limits
<
double
>::
infinity
();
if
(
!
std
::
isinf
(
ddS
))
ddS
*=
_beta
;
size_t
bv
=
_state
.
_b
[
v
];
size_t
nbv
=
(
bv
==
r
)
?
s
:
r
;
double
ddS
;
if
(
_state
.
virtual_remove_size
(
v
)
>
0
)
ddS
=
_state
.
virtual_move
(
v
,
bv
,
nbv
,
_entropy_args
);
else
ddS
=
std
::
numeric_limits
<
double
>::
infinity
();
double
Z
=
log_sum
(
0.
,
-
ddS
);
if
(
!
std
::
isinf
(
ddS
))
ddS
*=
_beta
;
size_t
tbv
=
_btemp
[
v
];
double
p
;
if
((
swap
)
?
tbv
!=
nbv
:
tbv
==
nbv
)
{
move_vertex
(
v
,
nbv
);
p
=
-
ddS
-
Z
;
}
else
{
p
=
-
Z
;
}
double
Z
=
log_sum
(
0.
,
-
ddS
);
if
(
swap
)
lp2
+=
p
;
else
lp1
+=
p
;
size_t
tbv
=
_btemp
[
v
];
if
(
tbv
==
nbv
)
{
move_vertex
(
v
,
nbv
);
lp
+=
-
ddS
-
Z
;
}
else
{
lp
+=
-
Z
;
}
if
(
!
swap
)
pop_b
();
}
pop_b
();
return
l
og_sum
(
lp1
,
lp2
)
-
log
(
2
)
;
return
l
p
;
}
bool
allow_merge
(
size_t
r
,
size_t
s
)
...
...
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