Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyFstat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gregory Ashton
PyFstat
Commits
157060f7
Commit
157060f7
authored
8 years ago
by
Gregory Ashton
Browse files
Options
Downloads
Patches
Plain Diff
Adds printing of twoF value when using BGSL
Also fixes big in generate_initial_p0
parent
a94d215e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyfstat.py
+21
-6
21 additions, 6 deletions
pyfstat.py
with
21 additions
and
6 deletions
pyfstat.py
+
21
−
6
View file @
157060f7
...
@@ -952,7 +952,7 @@ class MCMCSearch(BaseSearchClass):
...
@@ -952,7 +952,7 @@ class MCMCSearch(BaseSearchClass):
if
type
(
self
.
theta_initial
)
==
dict
:
if
type
(
self
.
theta_initial
)
==
dict
:
logging
.
info
(
'
Generate initial values from initial dictionary
'
)
logging
.
info
(
'
Generate initial values from initial dictionary
'
)
if
self
.
nglitch
>
1
:
if
hasattr
(
self
,
'
nglitch
'
)
and
self
.
nglitch
>
1
:
raise
ValueError
(
'
Initial dict not implemented for nglitch>1
'
)
raise
ValueError
(
'
Initial dict not implemented for nglitch>1
'
)
p0
=
[[[
self
.
generate_rv
(
**
self
.
theta_initial
[
key
])
p0
=
[[[
self
.
generate_rv
(
**
self
.
theta_initial
[
key
])
for
key
in
self
.
theta_keys
]
for
key
in
self
.
theta_keys
]
...
@@ -1006,12 +1006,17 @@ class MCMCSearch(BaseSearchClass):
...
@@ -1006,12 +1006,17 @@ class MCMCSearch(BaseSearchClass):
lnp_finite
=
copy
.
copy
(
lnp
)
lnp_finite
=
copy
.
copy
(
lnp
)
lnp_finite
[
np
.
isinf
(
lnp
)]
=
np
.
nan
lnp_finite
[
np
.
isinf
(
lnp
)]
=
np
.
nan
idx
=
np
.
unravel_index
(
np
.
nanargmax
(
lnp_finite
),
lnp_finite
.
shape
)
idx
=
np
.
unravel_index
(
np
.
nanargmax
(
lnp_finite
),
lnp_finite
.
shape
)
logging
.
info
((
'
Gen. new p0 from max lnp (walker {}, pos {})
'
'
which had twoF={}
'
)
.
format
(
idx
[
0
],
idx
[
1
],
lnl
[
idx
]))
p
=
pF
[
idx
]
p
=
pF
[
idx
]
p0
=
self
.
generate_scattered_p0
(
p
)
p0
=
self
.
generate_scattered_p0
(
p
)
self
.
search
.
BSGL
=
False
twoF
=
self
.
logl
(
p
,
self
.
search
)
self
.
search
.
BSGL
=
self
.
BSGL
logging
.
info
((
'
Gen. new p0 from pos {} which had det. stat.={:2.1f},
'
'
twoF={:2.1f} and lnp={:2.1f}
'
)
.
format
(
idx
[
1
],
lnl
[
idx
],
twoF
,
lnp_finite
[
idx
]))
return
p0
return
p0
def
get_save_data_dictionary
(
self
):
def
get_save_data_dictionary
(
self
):
...
@@ -1096,7 +1101,7 @@ class MCMCSearch(BaseSearchClass):
...
@@ -1096,7 +1101,7 @@ class MCMCSearch(BaseSearchClass):
return
False
return
False
def
get_max_twoF
(
self
,
threshold
=
0.05
):
def
get_max_twoF
(
self
,
threshold
=
0.05
):
"""
Returns the max
2F
sample and the corresponding 2F value
"""
Returns the max
likelihood
sample and the corresponding 2F value
Note: the sample is returned as a dictionary along with an estimate of
Note: the sample is returned as a dictionary along with an estimate of
the standard deviation calculated from the std of all samples with a
the standard deviation calculated from the std of all samples with a
...
@@ -1111,9 +1116,19 @@ class MCMCSearch(BaseSearchClass):
...
@@ -1111,9 +1116,19 @@ class MCMCSearch(BaseSearchClass):
logging
.
info
(
'
twoF values contain nan
'
)
logging
.
info
(
'
twoF values contain nan
'
)
idxs
=
np
.
isfinite
(
self
.
lnlikes
)
idxs
=
np
.
isfinite
(
self
.
lnlikes
)
jmax
=
np
.
nanargmax
(
self
.
lnlikes
[
idxs
])
jmax
=
np
.
nanargmax
(
self
.
lnlikes
[
idxs
])
max
twoF
=
self
.
lnlikes
[
jmax
]
max
logl
=
self
.
lnlikes
[
jmax
]
d
=
OrderedDict
()
d
=
OrderedDict
()
if
self
.
BSGL
:
if
hasattr
(
self
,
'
search
'
)
is
False
:
self
.
inititate_search_object
()
p
=
self
.
samples
[
jmax
]
self
.
search
.
BSGL
=
False
maxtwoF
=
self
.
logl
(
p
,
self
.
search
)
self
.
search
.
BSGL
=
self
.
BSGL
else
:
maxtwoF
=
maxlogl
repeats
=
[]
repeats
=
[]
for
i
,
k
in
enumerate
(
self
.
theta_keys
):
for
i
,
k
in
enumerate
(
self
.
theta_keys
):
if
k
in
d
and
k
not
in
repeats
:
if
k
in
d
and
k
not
in
repeats
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment