SparseMethod

class SparseMethod(*args)

Least squares solver using a sparse representation.

Available constructors:

SparseMethod(method)

SparseMethod(method, basisSequenceFactory, fittingAlgorithm)

Parameters:
methodLeastSquaresMethod

Least squares resolution method

basisSequenceFactoryBasisSequenceFactory

Basis enumeration algorithm

fittingAlgorithmFittingAlgorithm

Validation algorithm

Methods

computeWeightedDesign([whole])

Build the design matrix.

getBasis()

Accessor to the basis.

getClassName()

Accessor to the object's name.

getCurrentIndices()

Current indices accessor.

getGramInverse()

Get the inverse Gram matrix of input sample.

getGramInverseDiag()

Get the diagonal of the inverse Gram matrix.

getGramInverseTrace()

Get the trace of the inverse Gram matrix.

getH()

Get the projection matrix H.

getHDiag()

Get the diagonal of the projection matrix H.

getInitialIndices()

Initial indices accessor.

getInputSample()

Input sample accessor.

getName()

Accessor to the object's name.

getWeight()

Accessor to the weights.

hasName()

Test if the object is named.

setName(name)

Accessor to the object's name.

solve(rhs)

Solve the least-squares problem.

solveNormal(rhs)

Solve the least-squares problem using normal equation.

trashDecomposition()

Drop the current decomposition.

update(addedIndices, conservedIndices, ...)

Update the current decomposition.

Examples

>>> import openturns as ot
>>> basisSize = 3
>>> sampleSize = 5
>>> X = ot.Sample.BuildFromPoint(range(1, 1 + sampleSize))
>>> phis = [ot.SymbolicFunction(['x'], ['x^' + str(j + 1)]) for j in range(basisSize)]
>>> basis = ot.Basis(phis)
>>> proxy = ot.DesignProxy(X, phis)
>>> full = range(basisSize)
>>> design = ot.Matrix(proxy.computeDesign(full))
>>> method = ot.SparseMethod(ot.QRMethod(proxy, full))
>>> normal = ot.Normal([1.0] * sampleSize, [0.1] * sampleSize)
>>> y = normal.getRealization()
>>> yAt = design.transpose() * y
>>> x = method.solve(y)
__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.

G^{-1} = (X^T * X)^{-1}

Returns:
cCovarianceMatrix

The inverse Gram matrix.

getGramInverseDiag()

Get the diagonal of the inverse Gram matrix.

diag(G^{-1}) = diag((X^T * X)^{-1})

Returns:
dPoint

The diagonal of the inverse Gram matrix.

getGramInverseTrace()

Get the trace of the inverse Gram matrix.

Tr(G^{-1}) = Tr(x^T * x)^{-1}

Returns:
xfloat

The trace of inverse Gram matrix.

getH()

Get the projection matrix H.

H = X * (X^T * X)^{-1} * X^T

Returns:
hSymmetricMatrix

The projection matrix H.

getHDiag()

Get the diagonal of the projection matrix H.

H = X * (X^T * X)^{-1} * X^T

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.

\vect{a} = \argmin_{\vect{x} \in \Rset^P} ||M\vect{x}-\vect{b}||^2

Parameters:
bsequence of float

Second term of the equation

Returns:
aPoint

The solution.

solveNormal(rhs)

Solve the least-squares problem using normal equation.

M^T*M*x=M^T*b

Parameters:
bsequence of float

Second term of the equation

Returns:
xPoint

The solution.

trashDecomposition()

Drop the current decomposition.

update(addedIndices, conservedIndices, removedIndices, row=False)

Update the current decomposition.

Parameters:
addedIndicessequence of int

Indices of added basis terms.

conservedIndicessequence of int

Indices of conserved basis terms.

removedIndicessequence of int

Indices of removed basis terms.