Transformations

VectorSpaceLeastSquares.AbstractTransformationType
AbstractTransformation

Super 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]
end
source

The following methods are available and must be defined for any concrete subtype of AbstractTransformation

VectorSpaceLeastSquares.apply!Function
apply!(t::AbstractTransformation, tx::AbstractVector{Td}, x::AbstractVector{Td}) where Td<:Real

Apply the transformation t to x and store the result in tx.

source

Void transformation

It corresponds to $\varphi(x) = x$ for $x \in \mathbb{R}^d$.

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.LinearTransformationMethod
LinearTransformation(x::AbstractVector{<:AbstractVector{T}}) where T<:Real

Create 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.

source

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.GaussianTransformationType
GaussianTransformation{Td} <: AbstractTransformation where Td<:Real

Implement an Gaussian transformation of the data defined by $\varphi(x) = N((x - \alpha) / \sigma)$ where $N$ is the cdf of the standard Gaussian distribution

source
VectorSpaceLeastSquares.GaussianTransformationMethod
GaussianTransformation(x::AbstractVector{<:AbstractVector{T}}) where T<:Real

Create 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.

source

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.LogNormalTransformationType
LogNormalTransformation{Td} <: AbstractTransformation where Td<:Real

Implement 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.

source
VectorSpaceLeastSquares.LogNormalTransformationMethod
LogNormalTransformation(x::AbstractVector{<:AbstractVector{T}}) where T<:Real

Create 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.

source