Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gregory Ashton
PyFstat
Commits
61f325b0
Commit
61f325b0
authored
Nov 06, 2017
by
Gregory Ashton
Browse files
Adds basic marginal bayes factor calculation
parent
ee5f59e2
Changes
1
Show whitespace changes
Inline
Side-by-side
pyfstat/grid_based_searches.py
View file @
61f325b0
...
...
@@ -9,6 +9,7 @@ from collections import OrderedDict
import
numpy
as
np
import
matplotlib
import
matplotlib.pyplot
as
plt
from
scipy.misc
import
logsumexp
import
pyfstat.helper_functions
as
helper_functions
from
pyfstat.core
import
(
BaseSearchClass
,
ComputeFstat
,
...
...
@@ -707,6 +708,20 @@ class EarthTest(GridSearch):
np
.
savetxt
(
self
.
out_file
,
data
,
delimiter
=
' '
)
self
.
data
=
data
def
marginalised_bayes_factor
(
self
,
prior_widths
):
ndims
=
self
.
data
.
shape
[
1
]
-
1
params
=
[
np
.
unique
(
self
.
data
[:,
j
])
for
j
in
range
(
ndims
)]
twoF
=
self
.
data
[:,
-
1
].
reshape
(
tuple
([
len
(
p
)
for
p
in
params
]))
F
=
twoF
/
2.0
max_F
=
np
.
max
(
F
)
for
i
,
x
in
enumerate
(
params
[::
-
1
]):
if
len
(
x
)
>
1
:
dx
=
x
[
1
]
-
x
[
0
]
F
=
logsumexp
(
F
,
axis
=-
1
)
+
np
.
log
(
dx
)
-
np
.
log
(
prior_widths
[
i
])
else
:
F
=
np
.
squeeze
(
F
,
axis
=-
1
)
return
np
.
atleast_1d
(
F
)[
0
],
max_F
class
DMoff_NO_SPIN
(
GridSearch
):
""" DMoff test using SSBPREC_NO_SPIN """
...
...
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