(bandits, trial)
| 37 | |
| 38 | |
| 39 | def plot(bandits, trial): |
| 40 | x = np.linspace(0, 1, 200) |
| 41 | for b in bandits: |
| 42 | y = beta.pdf(x, b.a, b.b) |
| 43 | plt.plot(x, y, label=f"real p: {b.p:.4f}, win rate = {b.a - 1}/{b.N}") |
| 44 | plt.title(f"Bandit distributions after {trial} trials") |
| 45 | plt.legend() |
| 46 | plt.show() |
| 47 | |
| 48 | |
| 49 | def experiment(): |