Transformations
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]
endThe following methods are available and must be defined for any concrete subtype of AbstractTransformation
VectorSpaceLeastSquares.apply! — Functionapply!(t::AbstractTransformation, tx::AbstractVector{Td}, x::AbstractVector{Td}) where Td<:RealApply the transformation t to x and store the result in tx.
VectorSpaceLeastSquares.jacobian — Functionjacobian(t::AbstractTransformation, x::AbstractVector{<:Real}, i::Integer, j::Integer)Compute $\partial_{x_j} \varphi_i(x)$.
Void transformation
It corresponds to $\varphi(x) = x$ for $x \in \mathbb{R}^d$.
VectorSpaceLeastSquares.VoidTransformation — TypeVoidTransformation <: AbstractTransformationThis transformation does nothing.
Linear transformation
It corresponds to $\varphi: \mathbb{R}^d \to \mathbb{R}^d$ such that $\varphi(x) = (x - \alpha) * \sigma$ for where $\alpha, \sigma \in \mathbb{R}^d$ and * denotes a term by term multiplication. In the following, $\alpha$ is called the center and $\sigma$ is called the scale
VectorSpaceLeastSquares.LinearTransformation — TypeLinearTransformation{Td} <: AbstractTransformation where Td<:RealImplement a linear transformation of the data defined by $\varphi(x) = (x - \alpha) * \sigma$
VectorSpaceLeastSquares.getCenter — FunctiongetCenter(t::LinearTransformation{<:Real})Return the center α of the linear transformation
VectorSpaceLeastSquares.getScale — FunctiongetScale(t::LinearTransformation{<:Real}) = t.scaleReturn the scale σ of the linear transformation
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.
Gaussian transformation
It corresponds to $\varphi: \mathbb{R}^d \to \mathbb{R}^d$ such that $\varphi(x) = \mathcal{N}((x - \alpha) / \sigma)$ where $\alpha, \sigma \in \mathbb{R}^d$, $\mathcal{N}$ is the cumulative distribution function of the standard normal distribution and / denotes a term by term multiplication.
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.getMean — MethodgetMean(t::LinearTransformation{<:Real})Return the mean α of the Gaussian distribution
VectorSpaceLeastSquares.getSigma — MethodgetScale(t::LinearTransformation{<:Real}) = t.scaleReturn the standard deviation σ of the Gaussian distribution
VectorSpaceLeastSquares.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.
Log-normal transformation
It corresponds to $\varphi: \mathbb{R}^d \to \mathbb{R}^d$ such that $\varphi(x) = \mathcal{N}((\log(x) - \alpha) / \sigma)$ where $\alpha, \sigma \in \mathbb{R}^d$, $\mathcal{N}$ is the cumulative distribution function of the standard normal distribution and / denotes a term by term multiplication.
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.getMean — MethodgetMean(t::LinearTransformation{<:Real})Return the mean α of the underlying Gaussian distribution
VectorSpaceLeastSquares.getSigma — MethodgetScale(t::LinearTransformation{<:Real}) = t.scaleReturn the standard deviation σ of the underlying Gaussian distribution
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.