Skip to content

Commit

Permalink
FIX opt.t_1samp: zero-variance
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbrodbeck committed Feb 10, 2017
1 parent 2e4587e commit 351e187
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions eelbrain/_stats/opt.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,12 @@ def t_1samp(scalar[:,:] y, double[:] out):
denom += (y[case, i] - mean) ** 2
denom /= div
denom **= 0.5
if denom == 0:
if mean == 0:
out[i] = 0
else:
out[i] = np.inf
continue
out[i] = mean / denom


Expand Down Expand Up @@ -510,4 +516,10 @@ def t_1samp_perm(scalar[:,:] y, double[:] out, cnp.int8_t[:] sign):
denom += (case_buffer[case] - mean) ** 2
denom /= div
denom **= 0.5
if denom == 0:
if mean == 0:
out[i] = 0
else:
out[i] = np.inf
continue
out[i] = mean / denom

0 comments on commit 351e187

Please sign in to comment.