Skip to content

Commit 5b9d363

Browse files
committed
Convert error from absolute to relative
proportion_ci outputs absolute values, but plt.errorbar requires values relative to the original data. Update results images
1 parent b6a667c commit 5b9d363

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

examples/merrill_1984_fig_2c_2d.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,14 @@
142142
'Plurality'):
143143
x, y = zip(*sorted(count[method].items()))
144144
CE = np.array(y)/y_cw
145+
146+
# Add 95% confidence interval error bars (Clopper-Pearson exact method)
145147
ci = np.empty((2, len(y)))
146148
for i in range(len(y)):
147149
ci[:, i] = binomtest(y[i], y_cw[i]).proportion_ci()
148-
plt.errorbar(x, CE*100, ci*100, fmt='-', label=method)
150+
yerr = ci - CE
151+
yerr[0] = -yerr[0]
152+
plt.errorbar(x, CE*100, yerr*100, fmt='-', label=method)
149153
table.append([method, *CE*100])
150154

151155
print(tabulate(table, ["Method", *x], tablefmt="pipe", floatfmt='.1f'))
-226 Bytes
Loading
-120 Bytes
Loading

0 commit comments

Comments
 (0)