daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2.  
  3. n_sample = 1000
  4. true_coef = np.array([2.0, 3.0])
  5. u0 = np.array([0.0, 0.0])
  6. A0 = 0.1 * np.eye(2)
  7. sample_X = np.random.normal(size=(n_sample, 2))
  8. sample_y = np.dot(sample_X, true_coef.reshape(-1, 1)).reshape(-1,) + np.random.normal(size=n_sample)
  9.  
  10. tmp1 = np.linalg.inv(np.dot(sample_X.T, sample_X))
  11. tmp2 = np.dot(sample_X.T, sample_y.reshape(-1, 1))
  12. beta = np.dot(tmp1, tmp2)
  13. tmp1 = np.linalg.inv(np.dot(sample_X.T, sample_X) + A0)
  14. tmp2 = np.dot(np.dot(sample_X.T, sample_X), beta) + np.dot(A0, u0.reshape(-1, 1))
  15. estimation_coef = np.dot(tmp1, tmp2)
  16. print(estimation_coef)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top