Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. def poly_approx( x, y, m ):
  2. """Compute an approximation polynomial of degree m for the points (x,y)"""
  3.  
  4. s = np.zeros( x.shape )
  5. r2 = 0
  6.  
  7. V = np.vander( x, increasing=True )
  8.  
  9. feck = la.solve(V, y)
  10.  
  11. s = feck[0:m+1]
  12.  
  13. V_cut = V[:,:m+1]
  14.  
  15. r2 = la.norm( np.matmul(V_cut, s) - y )
  16. return s, r2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement