SHARE
TWEET

Untitled

a guest Sep 20th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '''MAIN PROGRAM'''
  2. def y(params, x):
  3.     y = np.empty(len(x))
  4.     for i in range(len(x)):
  5.         y[i] = params[0]*math.sin(x[i]) + params[1]*math.cos(x[i]) + \
  6.                     params[2]*math.sin(2*x[i]) + params[3]*math.cos(2*x[i])
  7.     return y
  8.  
  9. params_QR = lstsq_QR(A, y_values)
  10. params_SVD = lstsq_SVD(A, y_values)
  11.  
  12. y_QR = y(params_QR, x_values)
  13. y_SVD = y(params_SVD, x_values)
  14.  
  15. plt.plot(x_values, y_values, 'bs', \
  16.          x_values, y_QR, 'r--', \
  17.          x_values, y_SVD, 'g^')
  18. #plt.close()
  19.  
  20.  
  21. # min ||Ax - b||:
  22. min_diff = sl.norm(y_values - y_QR, 2)
  23. testt = sl.norm(y_QR - y_SVD, 2)
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top