mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
Merge pull request #86 from fjosw/fix/divide_by_zero_in_gamma_div
Prevent division by zero by setting values of gamma_div which are smaller than 1 to 1
This commit is contained in:
commit
5c06947eb6
1 changed files with 2 additions and 1 deletions
|
@ -260,6 +260,7 @@ class Obs:
|
|||
gamma_div = np.zeros(w_max)
|
||||
for r_name in e_content[e_name]:
|
||||
gamma_div += self._calc_gamma(np.ones((self.shape[r_name])), self.idl[r_name], self.shape[r_name], w_max, fft)
|
||||
gamma_div[gamma_div < 1] = 1.0
|
||||
e_gamma[e_name] /= gamma_div[:w_max]
|
||||
|
||||
if np.abs(e_gamma[e_name][0]) < 10 * np.finfo(float).tiny: # Prevent division by zero
|
||||
|
@ -1456,7 +1457,7 @@ def _covariance_element(obs1, obs2):
|
|||
continue
|
||||
gamma_div += calc_gamma(np.ones(obs1.shape[r_name]), np.ones(obs2.shape[r_name]), obs1.idl[r_name], obs2.idl[r_name], idl_d[r_name])
|
||||
e_N += len(idl_d[r_name])
|
||||
gamma /= gamma_div
|
||||
gamma /= max(gamma_div, 1.0)
|
||||
|
||||
# Bias correction hep-lat/0306017 eq. (49)
|
||||
dvalue += (1 + 1 / e_N) * gamma / e_N
|
||||
|
|
Loading…
Add table
Reference in a new issue