Skip to content

Commit

Permalink
Correct bfmi denominator (arviz-devs#991)
Browse files Browse the repository at this point in the history
* correct bfmi denominator

* update test_diagnostics.py

* fixed denominator and docs
  • Loading branch information
nitishp25 authored and percygautam committed Jan 14, 2020
1 parent c4029fd commit 18a1dc4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions arviz/stats/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def bfmi(data):
Examples
--------
Compute the BFMI of an InferenceData object
.. ipython::
In [1]: import arviz as az
Expand Down Expand Up @@ -526,9 +527,9 @@ def _bfmi(energy):
energy_mat = np.atleast_2d(energy)
num = np.square(np.diff(energy_mat, axis=1)).mean(axis=1) # pylint: disable=no-member
if energy_mat.ndim == 2:
den = _numba_var(svar, np.var, energy_mat, axis=1, ddof=0)
den = _numba_var(svar, np.var, energy_mat, axis=1, ddof=1)
else:
den = np.var(energy, axis=1)
den = np.var(energy, axis=1, ddof=1)
return num / den


Expand Down
2 changes: 1 addition & 1 deletion arviz/tests/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def data():
class TestDiagnostics:
def test_bfmi(self):
energy = np.array([1, 2, 3, 4])
assert_almost_equal(bfmi(energy), 0.8)
assert_almost_equal(bfmi(energy), 0.6)

def test_bfmi_dataset(self):
data = load_arviz_data("centered_eight")
Expand Down

0 comments on commit 18a1dc4

Please sign in to comment.