With the help of np.lagfit()
method, we can get the least squares fit of laguerre series of a given data by using np.lagfit()
method.
Syntax :
np.lagfit(x, y, deg)
Return : Return the least squares fit of laguerre series to data.
Example #1 :
In this example we can see that by using np.lagfit()
method, we are able to get the least squares fit of laguerre series of a given data.
# import numpy and lagfit import numpy as np
from numpy.polynomial.laguerre import lagfit
x, y = [ 1 , 2 ], [ 3 , 4 ]
deg = 2
# import np.lagfit() method gfg = lagfit(x, y, deg)
print (gfg)
|
Output :
[2.125 -0.125 -1.75]
Example #2 :
# import numpy and lagfit import numpy as np
from numpy.polynomial.laguerre import lagfit
x, y = [ 1 , 2 , 3 ], [ 3 , 4 , 5 ]
deg = 3
# import np.lagfit() method gfg = lagfit(x, y, deg)
print (gfg)
|
Output :
[3.06722689 -0.66386555 -0.40336134 0.40336134]