User's Guide
Kernel
Kernel can be specified as a matrix or as a function. It is possible to set arbitrary function of 2 variables or use one of predefined kernels.
Main.TurchinReg.getOpticsKernels — Method.getOpticsKernels(name::String, alpha::Real = 1.)Arguments
name- name of a kernelalpha- kernel function parameter
Returns: kernel, function of 2 variables.
Available kernels:
rectangular:
diffraction:
gaussian:
triangular:
dispersive:
exponential:
heaviside:
Main.TurchinReg.discretize_kernel — Method.discretize_kernel(basis::Basis, kernel::Function, measurement_points::AbstractVector{<:Real})Arguments
basis– basiskernel– kernel functionmeasurement_points– array of data points
Returns: discretized kernel K::Array{Real, 2}, $K_{mn} = \int\limits_a^b K(x, y_n) \psi_m(x) dx$ - matrix of size n$\times$m, where $m$ - number of basis functions, $n$ - number of data points.
Bases
Main.TurchinReg.Basis — Type.Abstract type for all bases.
Main.TurchinReg.omega — Method.omega(basis::Basis, order::Int)Arguments
basis- basisorder- order of derivatives
Returns: Omega::Array{Real, 2}, $\Omega_{mn} = \int\limits_a^b \frac{d^{order} \psi_m}{dx^{order}} \frac{d^{order} \psi_n}{dx^{order}}$ - matrix of size n$\times$n of the mean values of derivatives of order order, where n - number of functions in basis.
Fourier basis
Main.TurchinReg.FourierBasis — Type.Fourier basis with length $2n+1$: {$0.5$, $\sin(\frac{\pi (x - \frac{a+b}{2})}{b-a})$, $\cos(\frac{\pi (x - \frac{a+b}{2})}{b-a})$, ..., $\sin(\frac{\pi n (x - \frac{a+b}{2})}{b-a})$, $\cos(\frac{\pi n (x - \frac{a+b}{2})}{b-a})$}.
FourierBasis(a::Real, b::Real, n::Int)a, b – the beginning and the end of the segment n – number of harmonics
Fields
a::Real– beginning of the supportb::Real– end of the supportn::Int– number of harmonicsbasis_functions::AbstractVector– array of basis functions
Cubic Spline basis
Main.TurchinReg.CubicSplineBasis — Type.Cubic spline basis on given knots with length $n$.
CubicSplineBasis(
knots::AbstractVector{<:Real},
boundary_condition::Union{Tuple{Union{String, Nothing}, Union{String, Nothing}}, Nothing, String}=nothing
)CubicSplineBasis(
a::Real, b::Real, n::Int,
boundary_condition::Union{Tuple{Union{String, Nothing}, Union{String, Nothing}}, Nothing, String}=nothing
)knots – knots of spline boundary_condition – boundary conditions of basis functions. If tuple, the first element affects left bound, the second element affects right bound. If string, both sides are affected. Possible options: "dirichlet", nothing
Fields
a::Real– beginning of the support, matches the first element of the arrayknotsb::Real– end of the support, matches the last element of the arrayknotsknots::AbstractVector{<:Real}– array of points on which the spline is builtbasis_functions::AbstractVector– array of basis functions
Legendre polynomials basis
Main.TurchinReg.LegendreBasis — Type.Legendre polynomials basis with length $n$.
LegendreBasis(a::Real, b::Real, n::Int)a, b – the beginning and the end of the support n – number of basis functions
Fields
a::Real– beginning of the supportb::Real– end of the supportbasis_functions::AbstractVector{BaseFunction}– array of basis functions
Bernstein polynomials basis
Main.TurchinReg.BernsteinBasis — Type.Bernstein polynomials basis.
BernsteinBasis(
a::Real, b::Real, n::Int,
boundary_condition::Union{Tuple{Union{String, Nothing}, Union{String, Nothing}}, Nothing, String}=nothing
)a, b – the beginning and the end of the segment n – number of basis functions boundary_condition – boundary conditions of basis functions. If tuple, the first element affects left bound, the second element affects right bound. If string, both sides are affected. Possible options: "dirichlet", nothing.
Fields
a::Real– beginning of the supportb::Real– end of the supportbasis_functions::AbstractVector{Function}– array of basis functionsboundary_condition::Tuple{Union{String, Nothing}, Union{String, Nothing}}– boundary conditions of basis functions. Possible options:"dirichlet",nothing.
Parameters of reconstruction algorithm
Regularization parameters
Main.TurchinReg.AlphasType — Type.Abstract type for all algorithms for choosing regularization parameters
Main.TurchinReg.ArgmaxBAT — Type.$alphas = argmax(P(alphas|f))$ Mode of the distribution is found by sampling using BAT.jl
ArgmaxBAT(alphas::Union{AbstractVector{<:Real}, Nothing}=nothing,
lower::Union{AbstractVector{<:Real}, Nothing}=nothing,
higher::Union{AbstractVector{<:Real}, Nothing}=nothing,
initial::Union{AbstractVector{<:Real}, Nothing}=nothing,
algo::MCMCAlgorithm=MetropolisHastings(),
nchains::Int=2,
nsamples::Int=1e4,
)Fields
alphas::Union{AbstractVector{<:Real}, Nothing}– values of regularization parameterslower::Union{AbstractVector{<:Real}, Nothing}– lower possible values of regularization parametershigher::Union{AbstractVector{<:Real}, Nothing}– higher possible values of regularization parametersinitial::Union{AbstractVector{<:Real}, Nothing}– initial values of regularization parametersalgo::MCMCAlgorithm– algorithm of sampling (for more info see BAT.jl documentation)nchains::Int– number of chains to samplensamples::Int– number of samples
Main.TurchinReg.ArgmaxOptim — Type.$alphas = argmax(P(alphas|f))$ Mode of the distribution is found by sampling using Optim.jl
ArgmaxOptim(alphas::Union{AbstractVector{<:Real}, Nothing}=nothing,
lower::Union{AbstractVector{<:Real}, Nothing}=nothing,
higher::Union{AbstractVector{<:Real}, Nothing}=nothing,
initial::Union{AbstractVector{<:Real}, Nothing}=nothing,
algo=BFGS()
)Fields
alphas::Union{AbstractVector{<:Real}, Nothing}– values of regularization parameterslower::Union{AbstractVector{<:Real}, Nothing}– lower possible values of regularization parametershigher::Union{AbstractVector{<:Real}, Nothing}– higher possible values of regularization parametersinitial::Union{AbstractVector{<:Real}, Nothing}– initial values of regularization parametersalgo– algorithm of optimization (for more info see Optim.jl documentation)
Main.TurchinReg.Marginalize — Type.Allows to compute $\varphi$ averaging over all parameters
Marginalize()Fields
alphas::Nothing– no fixed regularization parameters
Main.TurchinReg.User — Type.User-defined parameters
User(alphas::AbstractVector{<:Real})Fields
alphas::AbstractVector{<:Real}– fixed regularization parameters
Reconstruction algorithms
Main.TurchinReg.AlgoType — Type.Abstract type for all solution algorithms
Main.TurchinReg.Analytically — Type.Analytical solution
Analytically()Fields no fields
Main.TurchinReg.BATSampling — Type.Solve with BATSampling
BATSampling(log_data_distribution::Union{Function, Nothing}=nothing,
algo::MCMCAlgorithm=MetropolisHastings(),
nchains::Int=2,
nsamples::Int=1e4
)Fields
log_data_distribution::Union{Function, Nothing}– logarithm of data distributionalgo::MCMCAlgorithm– algorithm foe sampling (foe more info see BAT.jlj documentation)nchains::Int– number of chains to samplensamples::Int– number of samples
Main.TurchinReg.AHMCSampling — Type.Solve with AHMCSampling
AHMCSampling(log_data_distribution::Union{Function, Nothing}=nothing,
nchains::Int=1,
nsamples::Int=1e4
)Fields
log_data_distribution::Union{Function, Nothing}– logarithm of data distributionnchains::Int– number of chains to samplensamples::Int– number of samples
Main.TurchinReg.DHMCSampling — Type.Solve with DHMCSampling
DHMCSampling(log_data_distribution::Union{Function, Nothing}=nothing,
nchains::Int=1,
nsamples::Int=1e4
)Fields
log_data_distribution::Union{Function, Nothing}– logarithm of data distributionnchains::Int– number of chains to samplensamples::Int– number of samples
Reconstruction
Main.TurchinReg.solve — Function.Solve the problem
solve(
basis::Basis,
data::Union{AbstractVector{<:Real}, Function},
data_errors::Union{AbstractVecOrMat{<:Real}, Function},
kernel::Union{Function, AbstractMatrix{<:Real}},
measurement_points::Union{AbstractVector{<:Real}, Nothing}=nothing,
algo::AlgoType=Analytically(),
alphas::AlphasType=ArgmaxBAT(),
omegas::Union{Array{Array{T, 2}, 1}, Nothing} where T<:Real = nothing,
phi_bounds::PhiBounds=PhiBounds(),
)Result
Main.TurchinReg.PhiVec — Type.Constructs solution function by coefficients, basis and errors.
PhiVec(coeff::Array{<:Real}, basis::Basis, errors::Array{<:Real})PhiVec(coeff::Array{<:Real}, basis::Basis)PhiVec(result::Dict{String, Array{<:Real}}, basis::Basis)Fields
coeff::Array{<:Real}– coefficients of decomposition of a function in basisbasis::Basis– basiserrors::Union{Array{<:Real}, Nothing}– coefficients of decomposition of a function errors in basissolution_function(x::Real)::Function – returns constructed function's value at given pointerror_function(x::Real)::Union{Function, Nothing} – returns constructed function's error at given point, if errors are specified, otherwise isnothingalphas::Union{AbstractVector{<:Real}, Nothing}– list of regularization parameters