Diagnostic functions
GPLinearODEMaker.est_dΣdθ
— Methodest_dΣdθ(glo, kernel_hyperparameters; return_est=true, return_anal=false, return_dif=false, return_bool=false, dif=1e-6, print_stuff=true)
Estimate the covariance derivatives of glo
(a GLOM model) at kernel_hyperparameters
with forward differences
Keyword Arguments
return_est::Bool=true
: Add the numerically estimated dΣdθs to the outputreturn_anal::Bool=false
: Add the analytical dΣdθs to the outputreturn_dif::Bool=false
: Add the difference between the dΣdθs to the outputreturn_bool::Bool=false
: Return just a similarity Booleandif::Real=1e-6
: The step size used in the forward difference methodprint_stuff::Bool=true
: Whether to print things
Output
- If
return_bool==true
, returns a Boolean for whether the analytical and
numerical estimates for the dΣdθs are approximately the same.
- Else returns a vector with some combination of the numerically estimated
dΣdθs, analytical dΣdθs, and differences between them
GPLinearODEMaker.est_∇
— Methodest_∇(f::Function, inputs::Vector{<:Real}; dif=1e-7, ignore_0_inputs=false)
Estimate the gradient of f
at inputs
with forward differences
Examples
julia> f(x) = x[1] + x[2]^2;
julia> isapprox([1,4], GPLinearODEMaker.est_∇(f, [2, 2.]); rtol=1e-5)
true
GPLinearODEMaker.est_∇nlogL_GLOM
— Methodest_∇nlogL_GLOM(glo, total_hyperparameters; dif=1e-7)
Estimate the gradient of nlogL_GLOM(glo, total_hyperparameters)
with forward differences
GPLinearODEMaker.est_∇∇
— Methodest_∇∇(g::Function, inputs::Vector{<:Real}; dif=1e-7, ignore_0_inputs=false)
Estimate the Hessian of a function whose gradients are provided by g
at inputs
with forward differences
Examples
julia> g(x) = [(x[2] ^ 2) / 2, x[1] * x[2]]; # h(x) = [0 x[2], x[2] x[1]]
julia> isapprox([0. 9; 9 4], GPLinearODEMaker.est_∇∇(g, [4., 9]); rtol=1e-5)
true
GPLinearODEMaker.est_∇∇_from_f
— Methodest_∇∇_from_f(f::Function, inputs::Vector{<:Real}; dif=1e-7, ignore_0_inputs=false)
Estimate the Hessian of f
at inputs
with forward differences. WARNING: The result is very sensitive to dif
Examples
julia> f(x) = (x[1] * x[2] ^ 2) / 2; # h(x) = [0 x[2], x[2] x[1]]
julia> isapprox([0. 9; 9 4], GPLinearODEMaker.est_∇∇_from_f(f, [4., 9]; dif=1e-4); rtol=1e-3)
true
GPLinearODEMaker.est_∇∇nlogL_GLOM
— Methodest_∇∇nlogL_GLOM(glo, total_hyperparameters; dif=1e-4)
Estimate the Hessian of nlogL_GLOM(glo, total_hyperparameters)
with forward differences
GPLinearODEMaker.test_∇
— Methodtest_∇(est_G, G; print_stuff=true, function_name="function")
Check if two gradient vectors (est_G
and G
) are approximately the same
Examples
julia> GPLinearODEMaker.test_∇([1., 2, 3], [1.0001, 2, 3]; print_stuff=false)
true
julia> GPLinearODEMaker.test_∇([1., 2, 3], [0., 2, 3]; print_stuff=false)
false
GPLinearODEMaker.test_∇nlogL_GLOM
— Methodtest_∇nlogL_GLOM(glo, kernel_hyperparameters; dif=1e-4, print_stuff=true)
Check if ∇nlogL_GLOM(glo, total_hyperparameters)
is close to numerical estimates provided by est_∇nlogL_GLOM(glo, total_hyperparameters)
GPLinearODEMaker.test_∇∇
— Methodtest_∇∇(est_H, H; print_stuff=true, function_name="function", rtol=1e-3)
Check if two Hessian matrices (est_H
and H
) are approximately the same
Examples
julia> GPLinearODEMaker.test_∇∇([1. 2; 3 4], [1.0001 2; 3 4]; print_stuff=false)
true
julia> GPLinearODEMaker.test_∇∇([1. 2; 3 4], [0. 2; 3 4]; print_stuff=false)
false
GPLinearODEMaker.test_∇∇nlogL_GLOM
— Methodtest_∇∇nlogL_GLOM(glo, kernel_hyperparameters; dif=1e-4, print_stuff=true)
Check if ∇∇nlogL_GLOM(glo, total_hyperparameters)
is close to numerical estimates provided by est_∇∇nlogL_GLOM(glo, total_hyperparameters)