Wendland Surrogate Tutorial

The Wendland surrogate is a compact surrogate: it allocates much less memory than other surrogates. The coefficients are found using an iterative solver.

$f = x -> exp(-x^2)$

using Surrogates
using Plots
n = 100
lower_bound = 0.0
upper_bound = 1.0
f = x -> exp(-x^2)
x = sample(n, lower_bound, upper_bound, SobolSample())
y = f.(x)
100-element Vector{Float64}:
 0.999450834440385
 0.7603420992361533
 0.5497973262437404
 0.9279586861644862
 0.8532075516884395
 0.4461099014964117
 0.6567372979278094
 0.9782072773172401
 0.956480737427535
 0.6032448395626249
 ⋮
 0.8397106792180511
 0.9177496036501366
 0.5332315942095883
 0.7446692912821248
 0.9981553899116735
 0.996572659247785
 0.7319617814344029
 0.5200533624689974
 0.9091637095195747

We choose to sample f in 100 points between 5 and 25 using sample function. The sampling points are chosen using a Sobol sequence, this can be done by passing SobolSample() to the sample function.

Building Surrogate

The choice of the right parameter is especially important here: a slight change in ϵ would produce a totally different fit. Try it yourself with this function!

wend = Wendland(x, y, lower_bound, upper_bound, eps = 0.45)
(::Wendland{Vector{Float64}, Vector{Float64}, Float64, Float64, Vector{Float64}, Int64, Float64, Float64}) (generic function with 1 method)
plot(x, y, seriestype = :scatter, label = "Sampled points",
    xlims = (lower_bound, upper_bound), legend = :top)
plot!(f, label = "True function", xlims = (lower_bound, upper_bound), legend = :top)
plot!(wend, label = "Surrogate function", xlims = (lower_bound, upper_bound), legend = :top)
Example block output