Skip to content

Commit

Permalink
adding prior_covariance and some general functions
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangil committed Apr 20, 2023
1 parent c72e488 commit 4d9494f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GPLinearODEMaker"
uuid = "27ef9b34-1325-4cec-ba33-00f2f4637873"
authors = ["Chistian Gilbertson <[email protected]>"]
version = "0.1.12"
version = "0.1.13"

[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
10 changes: 10 additions & 0 deletions src/general_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,13 @@ function log_laplace_approximation(
return logh - λ * g + 0.5 * (n * log(2 * π / λ) - logdet(H))

end


riffle(list_of_things::Vector{<:Vector{<:Real}}) = collect(Iterators.flatten(zip(list_of_things...)))
unriffle(riffled_list::Vector{<:Real}, n_out::Int) = [riffled_list[i:n_out:end] for i in 1:n_out]


remainder(vec, x) = [i > 0 ? i % x : (i % x) + x for i in vec]


rounded(x::Real) = round(x, digits=2)
8 changes: 8 additions & 0 deletions src/gp_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1272,3 +1272,11 @@ function reconstruct_total_hyperparameters(
return total_hyperparameters

end


function prior_covariance(kernel::Function, kernel_hyper::Vector{<:Real}, a0::Matrix{<:Real}, obs_xs::Vector{<:Real}; noise_list::Vector{<:Vector{<:Real}}=[zeros(length(obs_xs)) for i in axes(a0,1)], kwargs...)
total_hyper = append!(collect(Iterators.flatten(a0)), kernel_hyper)
glo = GLO(kernel, length(kernel_hyper), size(a0, 2), size(a0, 1), obs_xs, zeros(length(obs_xs) * size(a0, 1)); noise=collect(Iterators.flatten(zip(noise_list...))), a=a0, kwargs...)
Σ = Σ_observations(glo, total_hyper)
return Σ
end

0 comments on commit 4d9494f

Please sign in to comment.