Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def poly_approx( x, y, m ):
- """Compute an approximation polynomial of degree m for the points (x,y)"""
- s = np.zeros( x.shape )
- r2 = 0
- V = np.vander( x, increasing=True )
- feck = la.solve(V, y)
- s = feck[0:m+1]
- V_cut = V[:,:m+1]
- r2 = la.norm( np.matmul(V_cut, s) - y )
- return s, r2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement