-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_local.py
50 lines (34 loc) · 1.19 KB
/
error_local.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import time
import numpy as np
from matplotlib import pyplot as plt
from pyrbfpu.common import *
np.random.seed(12351)
points = np.random.uniform(0, 3, (200, 2))
def test_func(point):
x, y = point
r = np.sqrt(x ** 2 + y ** 2)
return np.sin(x) * np.cos(y) * (10 - r)
kernel = generate_kernel(inverse_multiquadric)
vals = np.array([test_func(x) for x in points])
targets = [RBFInterpolationRational, RBFInterpolationFastLinear]
fig = plt.figure()
for RBFInterpolation in targets:
rbf = RBFInterpolation(points, vals, kernel, 1.0, tol=1e-12)
rbf.estimate_error(0.1)
start = time.perf_counter()
rbf.optimize_param()
end = time.perf_counter()
print("TIME {}".format(end - start))
# print("TIME {} with EVALS {}".format(end - start, rbf.counter))
# start = time.perf_counter()
# for i in range(50):
# rbf.estimate_error(0.1)
# end = time.perf_counter()
# print("TIME ", end - start)
eps_space = np.linspace(0.01, 3.5, 200)
errors = np.array([rbf.estimate_error(eps) for eps in eps_space])
axes = fig.add_subplot(111)
axes.axvline(rbf.param)
axes.plot(eps_space, errors, "+", label=repr(RBFInterpolation))
plt.legend()
plt.show()