Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
probml
GitHub Repository: probml/pyprobml
Path: blob/master/deprecated/scripts/beta_bernoulli_bandit.py
1192 views
1
# Creates a figure for a beta distribution
2
# Author : Aleyna Kara (@karalleyna)
3
4
from scipy.stats import beta
5
import matplotlib.pyplot as plt
6
import numpy as np
7
8
a, b = 2, 2
9
theta_idx = 1
10
colors = ["tab:blue", "tab:orange"]
11
12
x = np.linspace(beta.ppf(0, a, b),beta.ppf(1, a, b), 100)
13
14
plt.figure(figsize=(7,7))
15
plt.xlim(0, 1)
16
plt.xticks([1])
17
plt.yticks([1])
18
plt.plot(x, beta.pdf(x, a, b), '-', c=colors[theta_idx-1], linewidth=3)
19
plt.xlabel(f'$\Theta_{theta_idx}$', fontsize='15')
20
plt.ylabel(f'f($\Theta_{theta_idx}$)', fontsize='15')
21
22
plt.savefig(f"action_{theta_idx}_{a}{b}.png", bbox_inches='tight')
23
plt.show()
24