Skip to content

Instantly share code, notes, and snippets.

@vutunganh
Created May 24, 2018 22:51
Show Gist options
  • Save vutunganh/51af91c7ce5b42789cf72c1ed1e08140 to your computer and use it in GitHub Desktop.
Save vutunganh/51af91c7ce5b42789cf72c1ed1e08140 to your computer and use it in GitHub Desktop.
Mereni
using MovingWeightedLeastSquares
f(x) = sin(2x)/2 + 10
function t()
xs = collect(-6:0.2:6)
fs = [f(x) for x in xs]
ε = 0.4
w = (d, eps) -> (exp(-d^2))
obj = mwls_naive(xs, fs, ε, w, maxDegree = 5)
for x in xs
res = obj(x)
ref = f(x)
@printf("%lf\t%lf\t%lf\t%lf\n", x, res, ref, abs(res - ref))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment