Skip to content

PosDef error for RBF kernel #402

@mjyshin

Description

@mjyshin

Hello, I am not sure if this is just on my machine, but I can't seem to sample from prior RBF GPs or posteriors trained on them. For instance, something as simple as

x = range(0,5,30)
f = GP(SEKernel())
plot(rand(f(x), 10))

results in the error

PosDefException: matrix is not positive definite; Cholesky factorization failed.

Stacktrace:
 [1] checkpositivedefinite
   @ ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/factorization.jl:67 [inlined]
 [2] cholesky!(A::Symmetric{Float64, Matrix{Float64}}, ::NoPivot; check::Bool)
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/cholesky.jl:269
 [3] cholesky! (repeats 2 times)
   @ ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/cholesky.jl:267 [inlined]
 [4] cholesky(A::Symmetric{Float64, Matrix{Float64}}, ::NoPivot; check::Bool)
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/cholesky.jl:401
 [5] cholesky (repeats 2 times)
   @ ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/cholesky.jl:401 [inlined]
 [6] rand(rng::Random._GLOBAL_RNG, f::AbstractGPs.FiniteGP{GP{ZeroMean{Float64}, SqExponentialKernel{Distances.Euclidean}}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Diagonal{Float64, FillArrays.Fill{Float64, 1, Tuple{Base.OneTo{Int64}}}}}, N::Int64)
   @ AbstractGPs ~/.julia/packages/AbstractGPs/IOYUf/src/finite_gp_projection.jl:235
 [7] rand(f::AbstractGPs.FiniteGP{GP{ZeroMean{Float64}, SqExponentialKernel{Distances.Euclidean}}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Diagonal{Float64, FillArrays.Fill{Float64, 1, Tuple{Base.OneTo{Int64}}}}}, N::Int64)
   @ AbstractGPs ~/.julia/packages/AbstractGPs/IOYUf/src/finite_gp_projection.jl:238
 [8] top-level scope
   @ In[128]:3

Unless I change the input sample size to something small like range(0,5,20).

Other kernels, e.g.,

x = range(0,5,30)
f = GP(Matern32Kernel())
plot(rand(f(x), 10))

run without any issue. Thank you in advance for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions