VectorSpaceLeastSquares.AbstractBasis — TypeAbstractBasisSuper type for all bases. A basis must implement the following methods: nVariates, length, getType, isDifferentiable, value. If the basis contains only differentiable functions, in which case isDifferentiable returns true, it must also implement derivative.
VectorSpaceLeastSquares.AbstractTransformation — TypeAbstractTransformationSuper type for all transformations.
A transformation is a function $\varphi: \mathbb{R}^d \to \mathbb{R}^d$, which is applied on the fly to the data before proceeding with the least squares problem. A transformation must implement apply! and jacobian.
To define a new transformation, define a new concrete subtype of AbstractTransformation and implement the corresponding apply! and jacobian methods. For instance the scaled log-transformation $\varphi(x) = \alpha \log(x)$ where $\alpha \in \mathbb{R}$ is defined as follows
struct LogTransformation <: AbstractTransformation
scale::Vector{<:Real}
end
function apply!(t::LogTransformation, tx::AbstractVector{Td}, x::AbstractVector{Td}) where Td<:Real
tx .= t.scale .* log.(x)
end
function jacobian(t::LogTransformation, x::AbstractVector{<:Real}, i::Integer, j::Integer)
if i != j
return 0.
end
t.scale[i] / x[i]
endVectorSpaceLeastSquares.GaussianTransformation — MethodGaussianTransformation(x::AbstractVector{<:AbstractVector{T}}) where T<:RealCreate a Gaussian transformation by setting α as the empirical mean and σ as the empirical standard deviation. Each entry of x is supposed to be one sample of the data.
VectorSpaceLeastSquares.GaussianTransformation — TypeGaussianTransformation{Td} <: AbstractTransformation where Td<:RealImplement an Gaussian transformation of the data defined by $\varphi(x) = N((x - \alpha) / \sigma)$ where $N$ is the cdf of the standard Gaussian distribution
VectorSpaceLeastSquares.LinearTransformation — MethodLinearTransformation(x::AbstractVector{<:AbstractVector{T}}) where T<:RealCreate a linear transformation by setting α as the empirical mean and σ as the inverse of the empirical standard deviation. Each entry of x is supposed to be one sample of the data.
VectorSpaceLeastSquares.LinearTransformation — TypeLinearTransformation{Td} <: AbstractTransformation where Td<:RealImplement a linear transformation of the data defined by $\varphi(x) = (x - \alpha) * \sigma$
VectorSpaceLeastSquares.LogNormalTransformation — MethodLogNormalTransformation(x::AbstractVector{<:AbstractVector{T}}) where T<:RealCreate a Log-normal transformation by setting α and σ as the empirical mean and variance of log(x) . Each entry of x is supposed to be one sample of the data.
VectorSpaceLeastSquares.LogNormalTransformation — TypeLogNormalTransformation{Td} <: AbstractTransformation where Td<:RealImplement a Log-normal transformation of the data defined by $\varphi(x) = N((\log(x) - \alpha) / \sigma)$ where $N$ is the cdf of the standard Gaussian distribution.
VectorSpaceLeastSquares.PiecewiseConstantBasis — MethodPiecewiseConstantBasis(nVariates::Integer, nIntervals::Integer)Create a PiecewiseConstantBasis with nIntervals along each direction.
VectorSpaceLeastSquares.PiecewiseConstantBasis — MethodPiecewiseConstantBasis(nVariates::Integer, nIntervals::Vector{<:Integer})Create a PiecewiseConstantBasis by specifying the number of intervals per direction (possibly different to allow non squared grids).
VectorSpaceLeastSquares.PiecewiseConstantBasis — TypePiecewiseConstantBasisRepresent a basis of local functions defined on $[0,1]^d$
nVariatesis the dimensiondof the space.nIntervalsis a vector of sizeddefining the number of sub-intervals to use along each dimension
VectorSpaceLeastSquares.PolynomialBasis — MethodPolynomialBasis(type::PolynomialType, nVariates::Integer, degree::Integer)Create a polynomial basis with type, nVariates variables and total maximum degree
VectorSpaceLeastSquares.PolynomialBasis — TypePolynomialBasisRepresent a multivariate polynomial
degree::Int64: maximum total degreenVariates::Int6: number of variatesdim::Int6: dimension of the generated vector spacetype::PolynomialType: a value fromPolynomialTypetensor::SparseMatrixCSC{Int64, Int64}: the sparse tensor representation of the polynomial. Polynomials are stored by column.
VectorSpaceLeastSquares.PolynomialType — TypePolynomialTypeList the families of polynomials available through the PolynomialBasis type
CanonicHermiteTchebychev
VectorSpaceLeastSquares.VSLeastSquares — MethodVSLeastSquares(basis::Tb, transform::Tt=VoidTransformation(), Td::Type=Float64) where {Tb<:AbstractBasis, Tt<:AbstractTransformation}Create a VSLeastSquares object from basis and transform and capable of handling Td typed data.
VectorSpaceLeastSquares.VSLeastSquares — TypeVSLeastSquares{Tb<:AbstractBasis, Tt<:AbstractTransformation, Td<:Real}The main object to solve a least squares problem.
VectorSpaceLeastSquares.VoidTransformation — TypeVoidTransformation <: AbstractTransformationThis transformation does nothing.
Base.length — Methodlength(b::AbstractBasis)Return the number of elements in the basis.
Base.length — Methodlength(vslsq::VSLeastSquares{Tb, Tt, Td}) where {Tb<:AbstractBasis, Tt<:AbstractTransformation, Td<:Real}Return the number of functions of the basis used to solve the least squares problem
Base.size — MethodBase.size — Methodsize(vslsq::VSLeastSquares{Tb, Tt, Td}) where {Tb<:AbstractBasis, Tt<:AbstractTransformation, Td<:Real}Return the tuple (nVariates, length)
VectorSpaceLeastSquares.apply! — Methodapply!(t::AbstractTransformation, tx::AbstractVector{Td}, x::AbstractVector{Td}) where Td<:RealApply the transformation t to x and store the result in tx.
VectorSpaceLeastSquares.derivative — Methodderivative(b::AbstractBasis, x::AbstractVector{<:Real}, index::Integer, derivativeIndex::Integer)Compute the value of the first derivative of the index-th basis function w.r.t to the derivativeIndex variate at point x.
VectorSpaceLeastSquares.derivative — Methodderivative(polType::PolynomialType, degree::Integer, x::Real)Evaluate the first derivative of a 1d polynomial of type polType and degree degree at x
VectorSpaceLeastSquares.derivative — Methodderivative(vslsq::VSLeastSquares{Tb, Tt, Td}, x::AbstractVector{Td}, index::Integer) where {Tb<:AbstractBasis, Tt<:AbstractTransformation, Td<:Real}Compute the partial derivative of the prediction w.r.t to the index variable.
The method fit must have been called before.
VectorSpaceLeastSquares.derivative — Methodderivative(p::PolynomialBasis, x::AbstractVector{Td}, polIndex::Ti, derivativeIndex::Ti) where {Td<:Real, Ti<:Integer}Evaluate the first partial derivative w.r.t variable derivativeIndex of the polIndex-th member of the polynomial basis p
VectorSpaceLeastSquares.fit — Methodfit(vslsq::VSLeastSquares{Tb, Tt, Td}, x::AbstractVector{<:AbstractVector{Td}}, y::AbstractVector{Td}) where {Tb<:AbstractBasis, Tt<:AbstractTransformation, Td<:Real}Solve the least squares problem.
VectorSpaceLeastSquares.fit — Methodfit(vslsq::VSLeastSquares{PiecewiseConstantBasis, Tt, Td}, x::AbstractVector{<:AbstractVector{Td}}, y::AbstractVector{Td}) where {Tt<:AbstractTransformation, Td<:Real}Solve the least squares problem using the specific structure of the PiecewiseConstantBasis.
VectorSpaceLeastSquares.getBasis — MethodgetBasis(vslsq::VSLeastSquares{Tb, Tt, Td}) where {Tb<:AbstractBasis, Tt<:AbstractTransformation, Td<:Real}Return the basis used to solve the least squares problem.
VectorSpaceLeastSquares.getCenter — MethodgetCenter(t::LinearTransformation{<:Real})Return the center α of the linear transformation
VectorSpaceLeastSquares.getCoefficients — MethodgetCoefficients(vslsq::VSLeastSquares{Tb, Tt, Td}) where {Tb<:AbstractBasis, Tt<:AbstractTransformation, Td<:Real}Return the coefficients solution to the least squares problem.
VectorSpaceLeastSquares.getMean — MethodgetMean(t::LinearTransformation{<:Real})Return the mean α of the Gaussian distribution
VectorSpaceLeastSquares.getMean — MethodgetMean(t::LinearTransformation{<:Real})Return the mean α of the underlying Gaussian distribution
VectorSpaceLeastSquares.getScale — MethodgetScale(t::LinearTransformation{<:Real}) = t.scaleReturn the scale σ of the linear transformation
VectorSpaceLeastSquares.getSigma — MethodgetScale(t::LinearTransformation{<:Real}) = t.scaleReturn the standard deviation σ of the Gaussian distribution
VectorSpaceLeastSquares.getSigma — MethodgetScale(t::LinearTransformation{<:Real}) = t.scaleReturn the standard deviation σ of the underlying Gaussian distribution
VectorSpaceLeastSquares.getType — MethodgetType(b::AbstractBasis)Return the internal basis type.
VectorSpaceLeastSquares.gradient — Methodgradient(vslsq::VSLeastSquares{Tb, Tt, Td}, x::AbstractVector{Td}) where {Tb<:AbstractBasis, Tt<:AbstractTransformation, Td<:Real}Compute the gradient of the prediction at x.
The method fit must have been called before.
VectorSpaceLeastSquares.isDifferentiable — MethodisDifferentiable(b::AbstractBasis)Return true if the functions in the basis are differentiable. In this case, a specific method derivative must be implemented.
VectorSpaceLeastSquares.jacobian — Methodjacobian(t::AbstractTransformation, x::AbstractVector{<:Real}, i::Integer, j::Integer)Compute $\partial_{x_j} \varphi_i(x)$.
VectorSpaceLeastSquares.nVariates — MethodnVariates(b::AbstractBasis)Return the number of variates of the functions inside the basis.
VectorSpaceLeastSquares.nVariates — MethodnVariates(vslsq::VSLeastSquares{Tb, Tt, Td}) where {Tb<:AbstractBasis, Tt<:AbstractTransformation, Td<:Real}Return the number of variates in the least squares problem
VectorSpaceLeastSquares.predict — Methodpredict(vslsq::VSLeastSquares{Tb, Tt, Td}, x::AbstractVector{Td}) where {Tb<:AbstractBasis, Tt<:AbstractTransformation, Td<:Real}Compute the value predicted by the least squares problem.
The method fit must have been called before.
VectorSpaceLeastSquares.predict — Methodpredict(vslsq::VSLeastSquares{PiecewiseConstantBasis, Tt, Td}, x::AbstractVector{Td}) where {Tt<:AbstractTransformation, Td<:Real}Compute the value predicted by the least squares problem using the specific structure of the PiecewiseConstantBasis.
The method fit must have been called before.
VectorSpaceLeastSquares.value — Methodvalue(b::AbstractBasis, x::AbstractVector{<:Real}, index::Integer)Compute the value of the index-th basis function at point x.
VectorSpaceLeastSquares.value — Methodvalue(p::PolynomialBasis, x::AbstractVector{<:Real}, i::Integer)Evaluate the i-th function of a Polynomial basis p at point x
VectorSpaceLeastSquares.value — Methodvalue(polType::PolynomialType, degree::Integer, x::Real)Evaluate a 1d polynomial of type polType and degree degree at x