Least squares fit of Laguerre series to data.
Return the coefficients of a Laguerre series of degree deg that is the least squares fit to the data values y given at points x. If y is 1D the returned coefficients will also be 1D. If y is 2D multiple fits are done, one for each column of y, and the resulting coefficients are stored in the corresponding columns of a 2D return. The fitted polynomial(s) are in the form
where n is deg.
Since numpy version 1.7.0, lagfit also supports NA. If any of the elements of x, y, or w are NA, then the corresponding rows of the linear least squares problem (see Notes) are set to 0. If y is 2D, then an NA in any row of y invalidates that whole row.
Parameters :  x : array_like, shape (M,)
y : array_like, shape (M,) or (M, K)
deg : int
rcond : float, optional
full : bool, optional
w : array_like, shape (M,), optional


Returns :  coef : ndarray, shape (M,) or (M, K)
[residuals, rank, singular_values, rcond] : present when full = True

Warns :  RankWarning :

See also
chebfit, legfit, polyfit, hermfit, hermefit
Notes
The solution is the coefficients of the Laguerre series p that minimizes the sum of the weighted squared errors
where the are the weights. This problem is solved by setting up as the (typically) overdetermined matrix equation
where V is the weighted pseudo Vandermonde matrix of x, c are the coefficients to be solved for, w are the weights, and y are the observed values. This equation is then solved using the singular value decomposition of V.
If some of the singular values of V are so small that they are neglected, then a RankWarning will be issued. This means that the coefficient values may be poorly determined. Using a lower order fit will usually get rid of the warning. The rcond parameter can also be set to a value smaller than its default, but the resulting fit may be spurious and have large contributions from roundoff error.
Fits using Laguerre series are probably most useful when the data can be approximated by sqrt(w(x)) * p(x), where w(x) is the Laguerre weight. In that case the weight sqrt(w(x[i]) should be used together with data values y[i]/sqrt(w(x[i]). The weight function is available as lagweight.
References
[R61]  Wikipedia, “Curve fitting”, http://en.wikipedia.org/wiki/Curve_fitting 
Examples
>>> from numpy.polynomial.laguerre import lagfit, lagval
>>> x = np.linspace(0, 10)
>>> err = np.random.randn(len(x))/10
>>> y = lagval(x, [1, 2, 3]) + err
>>> lagfit(x, y, 2)
array([ 0.96971004, 2.00193749, 3.00288744])