Skip to content

Instantly share code, notes, and snippets.

@twang2218
Last active October 14, 2020 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twang2218/0949efe864f3aadff5f6e4a74da7d79f to your computer and use it in GitHub Desktop.
Save twang2218/0949efe864f3aadff5f6e4a74da7d79f to your computer and use it in GitHub Desktop.
beta demo
from scipy.stats import beta
from scipy.stats import arcsine
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 1.0, 100)
x_ticks = np.linspace(0, 1.0, 5)
temp = np.linspace(10, 40, 5)
y11 = beta.pdf(x, 4, 7) * 0.6
y12 = beta.pdf(x, 9, 4) * 0.4
y1 = y11 + y12
y21 = beta.pdf(x, 9, 6) * 0.7
y22 = beta.pdf(x, 6, 9) * 0.3
y2 = y21 + y22
fig, axes = plt.subplots(3,1, figsize=(10,15))
ax = axes[0]
ax.plot(x, y11, 'b--')
ax.plot(x, y12, 'b--')
ax.plot(x, y1, 'b-')
ax.set_title('A (VIC)')
ax.set_xticks(x_ticks)
ax.set_xticklabels(temp)
ax = axes[1]
ax.plot(x, y21, 'r--')
ax.plot(x, y22, 'r--')
ax.plot(x, y2, 'r-')
ax.set_title('B (QLD)')
ax.set_xticks(x_ticks)
ax.set_xticklabels(temp)
ax = axes[2]
ax.plot(x, y1, 'b-')
ax.plot(x, y2, 'r-')
ax.plot(x, y1+y2, 'g--')
ax.set_title('A + B')
ax.set_xticks(x_ticks)
ax.set_xticklabels(temp)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment