Skip to content

Commit 77c0bba

Browse files
committed
fix minor error
1 parent 96be76d commit 77c0bba

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

lectures/util_rand_resp.md

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -609,45 +609,37 @@ mystnb:
609609
610610
π = 0.3
611611
n = 100
612-
613612
nv = [0.27, 0.34, 0.49, 0.74, 0.92, 1.1, 1.47, 2.94, 14.7]
614613
x = np.arange(0, 1, 0.001)
615-
y = [truth_border_function(i, π) for i in x]
614+
y = x - 0.4
616615
z = x
617616
x0 = np.arange(π, 1, 0.001)
618617
x2 = np.arange(0, π, 0.001)
619618
y1 = [π for i in x0]
620619
y2 = [π for i in x2]
621620
622-
# Calculate truth border more precisely
623-
threshold = π * (1 - π) / (1 - 2 * π)**2
624-
x3 = np.arange(threshold, 1, 0.001)
625-
y3 = [(xi**0.5 - (1 - π)**0.5)**2 for xi in x3]
626-
627621
plt.figure(figsize=(12, 10))
628622
plt.plot(x, x, 'c:', linewidth=2)
629-
plt.plot(x0, y1,'c:', linewidth=2)
630-
plt.plot(y2, x2,'c:', linewidth=2)
631-
plt.plot(x3, y3,'b-', linewidth=2, label='Truth Border')
632-
plt.fill_between(x, y, z, facecolor='blue', alpha=0.05, label='Truth telling')
633-
plt.fill_between(x3, 0, y3, facecolor='green', alpha=0.05, label='Lying')
634-
635-
# Plot iso-variance curves
623+
plt.plot(x0, y1, 'c:', linewidth=2)
624+
plt.plot(y2, x2, 'c:', linewidth=2)
625+
plt.plot(x, y, 'r-', label='Truth Border')
626+
plt.fill_between(x, y, z, facecolor='blue', alpha=0.05, label='truth telling')
627+
plt.fill_between(x, 0, y, facecolor='green', alpha=0.05, label='lying')
636628
for i in range(len(nv)):
637-
y_var = π - (π**2 * (1 - π)**2) / (n * (nv[i] / n) * (x0 - π + 1e-8))
638-
plt.plot(x0, y_var, 'k--', alpha=1 - 0.07 * i, label=f'V{i+1}')
629+
y = π - (π**2 * (1 - π)**2) / (n * (nv[i] / n) * (x0 - π + 1e-8))
630+
plt.plot(x0, y, 'k--', alpha=1 - 0.07 * i, label=f'V{i+1}')
639631
640-
# Plot the calculated optimal point
641-
plt.scatter(optimal_x, optimal_y, c='r', marker='*', label='Q (computed)', s=150)
632+
633+
plt.scatter(0.498, 0.1, c='b', marker='*', label='Q', s=150)
634+
plt.scatter(0.4, 0, c='y', label='X', s=150)
642635
plt.xlim([0, 1])
643636
plt.ylim([0, 0.5])
644637
plt.xlabel('Pr(A|yes)')
645638
plt.ylabel('Pr(A|no)')
646639
plt.text(0.45, 0.35, "Truth Telling", fontdict={'size':28, 'style':'italic'})
647-
plt.text(0.8, 0.1, "Lying", fontdict={'size':28, 'style':'italic'})
648-
plt.text(optimal_x + 0.02, optimal_y + 0.005, f"Optimal Design\n({optimal_x:.3f}, {optimal_y:.3f})",
649-
fontdict={'size':12,'color':'r'})
650-
plt.legend(loc='upper right', fontsize='medium')
640+
plt.text(0.85, 0.35, "Lying",fontdict = {'size':28, 'style':'italic'})
641+
plt.text(0.515, 0.095, "Optimal Design", fontdict={'size':16,'color':'b'})
642+
plt.legend(loc=0, fontsize='large')
651643
plt.show()
652644
```
653645

0 commit comments

Comments
 (0)