SHARE
TWEET

Untitled

a guest Oct 18th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. nobs = len(theta)
  2. M = np.column_stack((np.ones(nobs),np.cos(theta),np.sin(theta)))
  3. MTM = np.dot(np.transpose(M),M)
  4. MTMINV = np.linalg.inv(MTM)
  5. MTY = np.dot(np.transpose(M),data)
  6. P = np.dot(MTMINV,MTY)
  7. print('Solution = ',P)
  8.  
  9. Residuals = data - np.dot(M,P)
  10. ChiSq = np.dot(Residuals.transpose(),Residuals)
  11. RMS = math.sqrt(ChiSq/nobs)
  12.  
  13. print('RMS = %f'%(RMS))
  14.  
  15. C = MTMINV * ChiSq/(nobs-npar)  
  16.  
  17. # print solution
  18. print('Constant = %f +/- %f ' % (P[0],math.sqrt(C[0,0])))
  19. print('Linear   = %f +/- %f ' % (P[1],math.sqrt(C[1,1])))
  20. print('Quadratic= %f +/- %f ' % (P[2],math.sqrt(C[2,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
 
Top