Skip to content

Commit

Permalink
Some prior changes to make nicer plots
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanaelbosch committed Jun 4, 2024
1 parent 430729f commit 54731ad
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/priors/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ This implementation is likely to change in the future to allow for more flexibil
initial_distribution(p::AbstractGaussMarkovProcess{T}) where {T} = begin
d, q = dim(p), num_derivatives(p)
D = d * (q + 1)
initial_variance = ones(T, q + 1)
initial_variance = 1e-16*ones(T, q + 1)
μ0 = T <: LinearAlgebra.BlasFloat ? Array{T}(calloc, D) : zeros(T, D)
Σ0 = PSDMatrix(IsometricKroneckerProduct(d, diagm(sqrt.(initial_variance))))
return Gaussian(μ0, Σ0)
Expand Down
24 changes: 24 additions & 0 deletions src/priors/ioup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,30 @@ IOUP(num_derivatives; update_rate_parameter) = begin
IOUP(num_derivatives, missing; update_rate_parameter)
end

initial_distribution(p::IOUP{T}) where {T} = begin
d, q = dim(p), num_derivatives(p)
D = d * (q + 1)
if q > 0
initial_variance = 1e-8 * ones(T, q + 1)
μ0 = zeros(T, D)
Σ0 = PSDMatrix(
IsometricKroneckerProduct(d, diagm(sqrt.(initial_variance))),
)
return Gaussian(μ0, Σ0)
else
sde = to_sde(p)
μ0 = zeros(T, D)
Σ0 = PSDMatrix(
IsometricKroneckerProduct(
d,
Matrix(plyapc(sde.F.B, sde.L.B)'),
),
)
return Gaussian(μ0, Σ0)
end
end


remake(
p::IOUP{T};
elType=T,
Expand Down
8 changes: 7 additions & 1 deletion src/priors/matern.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ Matern(; dim, num_derivatives, lengthscale) =
Matern{typeof(1.0)}(; dim, num_derivatives, lengthscale)
Matern(num_derivatives, lengthscale) =
Matern(; dim=1, num_derivatives, lengthscale)
Matern(nu::Rational, lengthscale) =
Matern(; dim=1, nu, lengthscale)
Matern(; dim, nu::Rational, lengthscale) = begin
@assert nu.den == 2 "The Matern process is only defined for half integers nu = p/2"
Matern{typeof(1.0)}(;dim, num_derivatives=Int(floor(nu)), lengthscale)
end

remake(
p::Matern{T};
Expand All @@ -70,7 +76,7 @@ function to_sde(p::Matern)
l = p.lengthscale
@assert l isa Number

ν = q - 1 / 2
ν = q + 1 / 2
λ = sqrt(2ν) / l

F_breve = diagm(1 => ones(q))
Expand Down

0 comments on commit 54731ad

Please sign in to comment.