Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to new EKP (remove local posdef_correct) & typo fix #249

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ScalarRandomFeature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ function build_models!(
accelerator = optimizer_options["accelerator"]

initial_params = construct_initial_ensemble(rng, prior, n_ensemble)
min_complexity = log(regularization.λ)
min_complexity = n_features_opt * log(regularization.λ)
min_complexity = sqrt(abs(min_complexity))
data = vcat(get_outputs(io_pairs_opt)[(n_train + 1):end], 0.0, min_complexity)
ekiobj = EKP.EnsembleKalmanProcess(
Expand Down
28 changes: 0 additions & 28 deletions src/Utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export get_training_points
export get_obs_sample
export orig2zscore
export zscore2orig
export posdef_correct
"""
$(DocStringExtensions.TYPEDSIGNATURES)

Expand Down Expand Up @@ -120,31 +119,4 @@ function zscore2orig(Z::AbstractMatrix{FT}, mean::AbstractVector{FT}, std::Abstr
return X
end


"""
$(DocStringExtensions.TYPEDSIGNATURES)

Makes square matrix `mat` positive definite, by symmetrizing and bounding the minimum eigenvalue below by `tol`
"""
function posdef_correct(mat::AbstractMatrix; tol::Real = 1e8 * eps())
if !issymmetric(mat)
out = 0.5 * (mat + permutedims(mat, (2, 1))) #symmetrize
if isposdef(out)
# very often, small numerical errors cause asymmetry, so cheaper to add this branch
return out
end
else
out = mat
end

nugget = abs(minimum(eigvals(out)))
for i in 1:size(out, 1)
out[i, i] += nugget + tol #add to diag
end
return out
end




end # module
Loading