Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- beta = 1.41 #Yahoo finance
- import matplotlib.pyplot as plt
- from mpl_toolkits.mplot3d import Axes3D
- import matplotlib.mlab as mlab
- from scipy.stats import multivariate_normal
- def convert(a, b):
- current_stock_price = 27.96*beta*(1+a)
- #convert that market into a enterprise value
- eps = current_stock_price / b
- return eps
- total = []
- for i in range(10000):
- # draw a random chance market
- a = np.random.normal(loc=.05, scale=.21)
- b = np.random.normal(loc=17.51, scale = 2.44)
- total.append(convert(a,b))
- # fig = plt.figure()
- # n, bins, patches = plt.hist(total, bins=20, normed=1, facecolor='green', alpha=0.5)
- # mu, sigma = np.mean(total), np.std(total)
- # y = mlab.normpdf(bins, mu, sigma)
- # plt.plot(bins, y, 'r--')
- # plt.ylabel('Probability')
- # plt.xlabel('Earnings Per Share')
- # plt.title('Monte Carlo Prediction of Earnings Per Share')
- # info = "Mean: " + "%.2f"%mu +" | Standard Deviaiton: " + "%.2f"% sigma
- # plt.text(4, .65, info)
- # # Tweak spacing to prevent clipping of ylabel
- # plt.subplots_adjust(left=0.15)
- # plt.show()
- x = np.linspace(-1,1,500)
- y = np.linspace(0,32,500)
- X, Y = np.meshgrid(x,y)
- pos = np.empty(X.shape + (2,))
- pos[:, :, 0] = X; pos[:, :, 1] = Y
- mu = np.array([.05, 17.51])
- sigma = np.array([.21, 2.44])
- covariance = np.diag(sigma**2)
- z = multivariate_normal(mean=mu, cov=covariance).pdf(pos) * 17.51
- #Make a 3D plot
- fig = plt.figure()
- ax = fig.gca(projection='3d')
- ax.plot_surface(X, Y, z,cmap='viridis',linewidth=0)
- ax.set_xlabel('Projected Market Increase')
- ax.set_ylabel('Projected Price/Earning Ratio')
- ax.set_zlabel('Projected Earnings Per Share')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement