From 42523fb1c34c8fc598f866d179e281effcf08ae4 Mon Sep 17 00:00:00 2001
From: Moritz Huebner <moritz.huebner@ligo.org>
Date: Mon, 22 Apr 2019 20:05:02 -0500
Subject: [PATCH] Bayesian model dimensionality

---
 bilby/core/result.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/bilby/core/result.py b/bilby/core/result.py
index cbb6e4ee2..5937bcde1 100644
--- a/bilby/core/result.py
+++ b/bilby/core/result.py
@@ -535,6 +535,19 @@ class Result(object):
         """
         return self.posterior_volume / self.prior_volume(priors)
 
+    @property
+    def bayesian_model_dimensionality(self):
+        """ Characterises how many parameters are effectively constraint by the data
+
+        See <https://arxiv.org/abs/1903.06682>
+
+        Returns
+        -------
+        float: The model dimensionality
+        """
+        return 2 * (np.mean(self.posterior['log_likelihood']**2) -
+                    np.mean(self.posterior['log_likelihood'])**2)
+
     def get_one_dimensional_median_and_error_bar(self, key, fmt='.2f',
                                                  quantiles=(0.16, 0.84)):
         """ Calculate the median and error bar for a given key
-- 
GitLab