# QRMethod¶

class QRMethod(*args)

Least squares solver using the QR decomposition.

Available constructors:

QRMethod(proxy, weight, indices)

QRMethod(proxy, indices)

QRMethod(design)

Parameters:
proxyDesignProxy

Input sample

weightsequence of float

Output weights

indicessequence of int

Indices allowed in the basis

design2-d sequence of float

A priori known design matrix

Examples

Solves a linear least squares problem with SVD method:

>>> import openturns as ot
>>> A = ot.Matrix([[1, 1], [1, 2], [1, 3], [1, 4]])
>>> y = [6, 5, 7, 10]
>>> method = ot.QRMethod(A)
>>> x = method.solve(y)
>>> print(x)
[3.5,1.4]


Methods

 computeWeightedDesign([whole]) Build the design matrix. Accessor to the basis. Accessor to the object's name. Current indices accessor. Get the inverse Gram matrix of input sample. Get the diagonal of the inverse Gram matrix. Get the trace of the inverse Gram matrix. Get the projection matrix H. Get the diagonal of the projection matrix H. Initial indices accessor. Input sample accessor. Accessor to the object's name. Accessor to the weights. Test if the object is named. setName(name) Accessor to the object's name. solve(rhs) Solve the least-squares problem. Solve the least-squares problem using normal equation. Drop the current decomposition. update(addedIndices, conservedIndices, ...) Update the current decomposition.
__init__(*args)
computeWeightedDesign(whole=False)

Build the design matrix.

Parameters:
wholebool, defaults to False

Whether to use the initial indices instead of the current indices

Returns:
psiAkMatrix

The design matrix

getBasis()

Accessor to the basis.

Returns:
basiscollection of Function

Basis.

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

The object class name (object.__class__.__name__).

getCurrentIndices()

Current indices accessor.

Returns:
indicesIndices

Indices of the current decomposition in the global basis.

getGramInverse()

Get the inverse Gram matrix of input sample.

Returns:
cCovarianceMatrix

The inverse Gram matrix.

getGramInverseDiag()

Get the diagonal of the inverse Gram matrix.

Returns:
dPoint

The diagonal of the inverse Gram matrix.

getGramInverseTrace()

Get the trace of the inverse Gram matrix.

Returns:
xfloat

The trace of inverse Gram matrix.

getH()

Get the projection matrix H.

Returns:
hSymmetricMatrix

The projection matrix H.

getHDiag()

Get the diagonal of the projection matrix H.

Returns:
dPoint

The diagonal of H.

getInitialIndices()

Initial indices accessor.

Returns:
indicesIndices

Initial indices of the terms in the global basis.

getInputSample()

Input sample accessor.

Returns:
inputSampleSample

Input sample.

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getWeight()

Accessor to the weights.

Returns:
weightPoint

Weights.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

solve(rhs)

Solve the least-squares problem.

Parameters:
bsequence of float

Second term of the equation

Returns:
aPoint

The solution.

solveNormal(rhs)

Solve the least-squares problem using normal equation.

Parameters:
bsequence of float

Second term of the equation

Returns:
xPoint

The solution.

trashDecomposition()

Drop the current decomposition.

Update the current decomposition.

Parameters:

conservedIndicessequence of int

Indices of conserved basis terms.

removedIndicessequence of int

Indices of removed basis terms.

## Examples using the class¶

Compute leave-one-out error of a polynomial chaos expansion

Compute leave-one-out error of a polynomial chaos expansion

Compute confidence intervals of a regression model from data

Compute confidence intervals of a regression model from data

Compute confidence intervals of a univariate noisy function

Compute confidence intervals of a univariate noisy function