Package gmisclib :: Module gpk_rlsq :: Class w_linear_least_squares
[frames] | no frames]

Class w_linear_least_squares

source code


This solves the set of linear equations a*x = y, with weights w. Normally, a.shape==(m,n) and y.shape==(m,q), and the returned x.shape==(n,q). where m is the number of constraints provided by the data, n is the number of parameters to use in a fit (equivalently, the number of basis functions), and q is the number of separate sets of equations that you are fitting. Then, x has shape (n,q) and the_fit has shape (m,q). Interpreting this as a linear regression, there are n parameters in the model, and m measurements. Q is the number of times you apply the model to a different data set; each on yields a different solution.

This uses gpk_lsq.linear_least_squares as the underlying algorithm.


Note: Y may be a 1-D matrix (a vector), in which case the fit is a vector. This is the normal case where you are fitting one equation. If y is a 2-D matrix, each column (second index) in y is a separate fit, and each column in the solution is a separate result.

Instance Methods
 
__init__(self, a, y, w, minsv=None, minsvr=None, copy=True)
This solves the set of linear equations a*x = y, and allows you to get properties of the fit via methods.
source code
 
fit(self, copy=False) source code
 
y(self, copy=True) source code
 
set_y(self, y, copy=True) source code
 
residual(self) source code
float
eff_n(self)
Returns something like the number of data, except that it looks at their weighting and the structure of the problem. (Inherited from gmisclib.gpk_lsq.lls_base)
source code
float
eff_rank(self)
Returns something like the rank of the solution, but rather than counting how many dimensions can be solved at all, it reports how many dimensions can be solved with a relatively good accuracy. (Inherited from gmisclib.gpk_lsq.linear_least_squares)
source code
 
hat(self, copy=True)
Hat Matrix Diagonal Data points that are far from the centroid of the X-space are potentially influential. (Inherited from gmisclib.gpk_lsq.linear_least_squares)
source code
 
rank(self) (Inherited from gmisclib.gpk_lsq.linear_least_squares) source code
 
sv(self) (Inherited from gmisclib.gpk_lsq.linear_least_squares) source code
 
variance_about_fit(self)
Returns the estimator of the standard deviation of the data about the fit. (Inherited from gmisclib.gpk_lsq.lls_base)
source code
 
x(self, y=None, copy=True) (Inherited from gmisclib.gpk_lsq.lls_base) source code
 
x_variances(self)
Estimated standard deviations of the solution. (Inherited from gmisclib.gpk_lsq.linear_least_squares)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, a, y, w, minsv=None, minsvr=None, copy=True)
(Constructor)

source code 

This solves the set of linear equations a*x = y, and allows you to get properties of the fit via methods. Normally, a.shape==(m,n) and y.shape==(m,q), and the returned x.shape==(n,q). where m is the number of constraints provided by the data, n is the number of parameters to use in a fit (equivalently, the number of basis functions), and q is the number of separate sets of equations that you are fitting. Then, self.x() has shape (n,q) and self.the_fit() has shape (m,q). Interpreting this as a linear regression, there are n parameters in the model, and m measurements. Q is the number of times you apply the model to a different data set; each on yields a different solution.

The procedure uses a singular value decomposition algorithm, and treats all singular values that are smaller than minsv as zero (i.e. drops them). If minsvr is specified, it treates all singular values that are smaller than minsvr times the largest s.v. as zero. The returned rank is the rank of the solution, which is normally the number of nonzero elements in x. Note that the shape of the solution vector or matrix is defined by a and y, and the rank can be smaller than m.

Overrides: object.__init__
(inherited documentation)

fit(self, copy=False)

source code 
Raises:
  • numpy.linalg.linalg.LinAlgError - when the matrix is singular.
Overrides: gpk_lsq.lls_base.fit

Note: all elements of w must be nonzero.

y(self, copy=True)

source code 
Overrides: gpk_lsq.lls_base.y

set_y(self, y, copy=True)

source code 
Overrides: gpk_lsq.lls_base.set_y

residual(self)

source code 
Overrides: gpk_lsq.lls_base.residual