Smoothing interpolation for tachometer data

@marius311, looking at the Loess.jl page, the robust fit smooth line seems to be way off?

Tested it below against SmoothingSplines.jl. and good results were obtained using your recommended Loess span parameter.

using Loess, SmoothingSplines, Plots
xs = sort(10 .* rand(200))
ys = sin.(xs)
yn = ys .+ (rand(200) .- 0.5)
yn[96:2:104] .= 2.9;  # Add massive outliers
model = loess(xs, ys, span=0.5)
# us = range(extrema(xs)...; step = 0.1)
vs = Loess.predict(model, xs)

Plots.plot(xs, ys, label="True signal", ylims=(-2.0,3))
Plots.scatter!(xs, yn, ms=3, label="Noisy samples w/ outliers")
Plots.plot!(xs, vs, ls=:dash, label="Loess.jl")

spl = fit(SmoothingSpline, xs, ys, 1.0) # λ=1.0
yp = SmoothingSplines.predict(spl,xs) # fitted vector
Plots.plot!(xs, yp, lc=:red,ls=:dash,label="(Cubic) SmoothingSpline.jl")

Loess_vs_SmoothingSplines

2 Likes