SparseMethod¶
- class SparseMethod(*args)¶
Least squares solver using a sparse representation.
- Available constructors:
SparseMethod(method)
SparseMethod(method, basisSequenceFactory, fittingAlgorithm)
- Parameters:
- method
LeastSquaresMethod
Least squares resolution method
- basisSequenceFactory
BasisSequenceFactory
Basis enumeration algorithm
- fittingAlgorithm
FittingAlgorithm
Validation algorithm
- method
Methods
computeWeightedDesign
([whole])Build the design matrix.
getBasis
()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.
getH
()Get the projection matrix H.
getHDiag
()Get the diagonal of the projection matrix H.
Initial indices accessor.
Input sample accessor.
getName
()Accessor to the object's name.
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.
Drop the current decomposition.
update
(addedIndices, conservedIndices, ...)Update the current decomposition.
See also
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:
- psiAk
Matrix
The design matrix
- psiAk
- getClassName()¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- getCurrentIndices()¶
Current indices accessor.
- Returns:
- indices
Indices
Indices of the current decomposition in the global basis.
- indices
- getGramInverse()¶
Get the inverse Gram matrix of input sample.
- Returns:
- c
CovarianceMatrix
The inverse Gram matrix.
- c
- getGramInverseDiag()¶
Get the diagonal of the inverse Gram matrix.
- Returns:
- d
Point
The diagonal of the inverse Gram matrix.
- d
- getGramInverseTrace()¶
Get the trace of the inverse Gram matrix.
- Returns:
- xfloat
The trace of inverse Gram matrix.
- getH()¶
Get the projection matrix H.
- Returns:
- h
SymmetricMatrix
The projection matrix H.
- h
- getInitialIndices()¶
Initial indices accessor.
- Returns:
- indices
Indices
Initial indices of the terms in the global basis.
- indices
- getName()¶
Accessor to the object’s name.
- Returns:
- namestr
The name of the object.
- 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:
- a
Point
The solution.
- a
- solveNormal(rhs)¶
Solve the least-squares problem using normal equation.
- Parameters:
- bsequence of float
Second term of the equation
- Returns:
- x
Point
The solution.
- x
- 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.