plot_votes_distrib.py 485 B

1234567891011121314151617181920212223
  1. import numpy as np
  2. from scipy.stats import dirichlet
  3. import ternary
  4. scale = 60
  5. x = np.load("votes_distrib.npz")
  6. alphas = x["alphas"].mean(axis=0)
  7. def prob(p):
  8. p = np.array(p)
  9. print(p)
  10. if np.all(p>0):
  11. return dirichlet.logpdf(p, alphas)
  12. else:
  13. return 0
  14. figure, tax = ternary.figure(scale=scale)
  15. tax.heatmapf(prob, boundary=True, style="triangular")
  16. tax.boundary(linewidth=2.0)
  17. tax.set_title("Shannon Entropy Heatmap")
  18. tax.savefig("votes_distrib.eps")