Commit 61f325b0 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Adds basic marginal bayes factor calculation

parent ee5f59e2
......@@ -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=' ') = data
def marginalised_bayes_factor(self, prior_widths):
ndims =[1] - 1
params = [np.unique([:, j]) for j in range(ndims)]
twoF =[:, -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])
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 """
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment