Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import numpy as np
  2. import statsmodels.api as sm
  3. import matplotlib.pyplot as plt
  4.  
  5. N, M = 100, 10
  6. b_N, b_M = [], []
  7.  
  8. for i in range(5000):
  9. x = np.random.random(N)
  10. y = 2*x + 1 + np.random.random(N)
  11. _, b_1 = sm.OLS(y, sm.add_constant(x)).fit().params
  12. b_N.append(b_1)
  13. _, b_1 = sm.OLS(y[:M], sm.add_constant(x[:M])).fit().params
  14. b_M.append(b_1)
  15.  
  16. plt.hist(b_M)
  17. plt.hist(b_N)
  18. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement