Guest User

Contour plot for net CAGR of normally distributed returns

a guest
Dec 17th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import matplotlib  
  2. matplotlib.use('TkAgg')
  3.  
  4. from mpl_toolkits.mplot3d import Axes3D
  5. import matplotlib.pyplot as plt
  6.  
  7. def norm_data():
  8.     '''Return normalized data'''
  9.     cagrs = []
  10.     mus = range(0, 100)
  11.     sigmas = [x*0.5 for x in range(0, 200)]
  12.     for sigma in tqdm(sigmas):
  13.         cagr = []
  14.         for mu in mus:
  15.             cagr.append(normal_returns(mu, sigma))
  16.         cagrs.append(cagr)
  17.     return (mus, sigmas, cagrs)
  18.  
  19. norm_x, norm_y, norm_z = norm_data()
  20.  
  21. fig = plt.figure()
  22. cp = plt.contour(norm_x, norm_y, norm_z)
  23. plt.clabel(cp, inline=True, fontsize=10)
  24. plt.title('Net CAGR')
  25. plt.xlabel('Mean Returns')
  26. plt.ylabel('Deviation')
  27. plt.show()
Add Comment
Please, Sign In to add comment