Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
Xavier Garrido
CAMEL
Commits
a95e36a4
Commit
a95e36a4
authored
Jun 14, 2017
by
Matthieu Tristram
Browse files
Duplicate plot_correlation
parent
c3886afb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
work/tools/python/camel.py
work/tools/python/camel.py
+15
-11
No files found.
work/tools/python/camel.py
View file @
a95e36a4
...
...
@@ -207,9 +207,8 @@ def cov2cor( mat):
########################################################################
#CONVERGENCE
########################################################################
def
GelmanRubin
(
chains
,
gap
=
10000
,
length_max
=
None
,
new
=
False
):
length_min
=
1000
def
GelmanRubin
(
chains
,
gap
=
10000
,
length_min
=
1000
,
length_max
=
None
,
new
=
False
):
#plot GelmanRubin test skipping first parameter=chi2
nchain
=
len
(
chains
)
nsamples
=
min
(
[
len
(
c
[
0
])
for
c
in
chains
])
...
...
@@ -227,11 +226,11 @@ def GelmanRubin( chains, gap=10000, length_max=None, new=False):
if
new
:
#Gelman-Rubin stat on the last "gap" samples for each iteration
n
=
gap
tmp
=
[
data
[:,
isamp
:
isamp
+
gap
]
for
data
in
chains
]
tmp
=
[
data
[
1
:,
isamp
:
isamp
+
gap
]
for
data
in
chains
]
else
:
#Gelman-Runbin stat on the last half samples for each iteration
n
=
(
isamp
-
length_min
)
/
2
tmp
=
[
data
[:,
length_min
+
n
:
isamp
]
for
data
in
chains
]
tmp
=
[
data
[
1
:,
length_min
+
n
:
isamp
]
for
data
in
chains
]
#within Chain
mchain
=
np
.
mean
(
tmp
,
2
)
...
...
@@ -788,17 +787,20 @@ def hist1d(x, bins=50, weights=None, smooth=0., normmax=True, **kwargs):
def
plot_correlation
(
chain
,
par
,
**
kwargs
):
def
MCcorrelation
(
chain
,
par
,
**
kwargs
):
data
=
[
chain
[
p
]
for
p
in
par
]
matC
=
np
.
corrcoef
(
data
)
plot_correlation
(
matC
,
par
,
**
kwargs
)
def
plot_correlation
(
matC
,
par
,
**
kwargs
):
vmin
=
kwargs
.
pop
(
"vmin"
,
-
1
)
vmax
=
kwargs
.
pop
(
"vmax"
,
1
)
data
=
[
chain
[
p
]
for
p
in
par
]
plt
.
figure
(
figsize
=
(
14
,
10
))
#covmat = np.triu(np.corrcoef( chain.values()[1:]), k=1)
matC
=
np
.
corrcoef
(
data
)
covmat
=
np
.
tril
(
matC
,
k
=-
1
)
covmat
[
covmat
==
0
]
=
np
.
NaN
plt
.
imshow
(
covmat
,
vmin
=
vmin
,
vmax
=
vmax
,
**
kwargs
)
...
...
@@ -809,6 +811,8 @@ def plot_correlation( chain, par, **kwargs):
# text( i, i+0.25, parname.get(par[i+1],par[i+1]),rotation=-90)
plt
.
text
(
i
-
0.25
,
i
+
0.25
,
parname
.
get
(
par
[
i
],
par
[
i
]),
rotation
=
'vertical'
,
verticalalignment
=
'bottom'
)
########################################################################
...
...
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