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
4590f1cc
Commit
4590f1cc
authored
Jul 21, 2016
by
Tiago Peixoto
Browse files
test_inference_mcmc.py: some tuning
parent
df29e859
Changes
2
Show whitespace changes
Inline
Side-by-side
doc/pyenv.py
View file @
4590f1cc
...
...
@@ -47,6 +47,7 @@ import numpy as np
from
pylab
import
*
from
numpy
import
*
import
graph_tool.all
as
gt
import
random
as
prandom
figure
()
...
...
@@ -54,5 +55,7 @@ try:
gt
.
openmp_set_num_threads
(
1
)
except
RuntimeError
:
pass
prandom
.
seed
(
42
)
np
.
random
.
seed
(
42
)
gt
.
seed_rng
(
42
)
doc/test_inference_mcmc.py
View file @
4590f1cc
...
...
@@ -112,7 +112,7 @@ for directed in [True, False]:
state
=
minimize_blockmodel_dl
(
g
,
deg_corr
=
True
)
state
=
state
.
copy
(
B
=
g
.
num_vertices
())
cs
=
list
(
reversed
([
numpy
.
inf
,
1
,
0.1
,
0.01
,
0.001
,
"gibbs"
]))
cs
=
list
(
reversed
([
numpy
.
inf
,
1
,
0.1
,
0.01
,
"gibbs"
]))
for
i
,
c
in
enumerate
(
cs
):
if
c
!=
"gibbs"
:
...
...
@@ -124,7 +124,7 @@ for directed in [True, False]:
mcmc_args
=
mcmc_args
,
gibbs
=
c
==
"gibbs"
,
nbreaks
=
5
,
wait
=
1
00
,
wait
=
50
00
,
verbose
=
(
1
,
"c = %s (t) "
%
str
(
c
))
if
verbose
else
False
)
hists
[
c
]
=
mcmc_equilibrate
(
state
,
mcmc_args
=
mcmc_args
,
...
...
@@ -144,17 +144,17 @@ for directed in [True, False]:
Ss1
=
array
(
list
(
zip
(
*
hists
[
c1
]))[
0
])
Ss2
=
array
(
list
(
zip
(
*
hists
[
c2
]))[
0
])
# add very small normal noise, to solve discreteness issue
Ss1
+=
numpy
.
random
.
normal
(
0
,
1e-
6
,
len
(
Ss1
))
Ss2
+=
numpy
.
random
.
normal
(
0
,
1e-
6
,
len
(
Ss2
))
Ss1
+=
numpy
.
random
.
normal
(
0
,
1e-
2
,
len
(
Ss1
))
Ss2
+=
numpy
.
random
.
normal
(
0
,
1e-
2
,
len
(
Ss2
))
D
,
p
=
scipy
.
stats
.
ks_2samp
(
Ss1
,
Ss2
)
D_c
=
1.63
*
sqrt
((
len
(
Ss1
)
+
len
(
Ss2
))
/
(
len
(
Ss1
)
*
len
(
Ss2
)))
if
verbose
:
print
(
"directed:"
,
directed
,
"c1:"
,
c1
,
"c2:"
,
c2
,
"D:"
,
D
,
"D_c:"
,
D_c
,
"p-value:"
,
p
)
if
p
<
.
01
:
if
p
<
.
0
01
:
print
((
"Warning, distributions for directed=%s (c1, c2) = "
+
"(%s, %s) are not the same, with a p-value: %g (D=%g)"
)
%
(
str
(
directed
),
str
(
c1
),
str
(
c2
),
p
,
D
))
"(%s, %s) are not the same, with a p-value: %g (D=%g
, D_c=%g
)"
)
%
(
str
(
directed
),
str
(
c1
),
str
(
c2
),
p
,
D
,
D_c
))
for
cum
in
[
True
,
False
]:
clf
()
...
...
Write
Preview
Markdown
is supported
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