Added scipy RBF interpolation#21
Conversation
Added scipy RBF interpolation
| return points | ||
|
|
||
|
|
||
| def rbf(points): |
There was a problem hiding this comment.
Old rbf() function is completely removed.
| import multiprocessing as mp | ||
| import numpy as np | ||
| import scipy.optimize as op | ||
| from scipy.interpolate import Rbf as rbf |
There was a problem hiding this comment.
Import Rbf() function from scipy as rbf().
|
|
||
| # sampling next batch of points | ||
| fit = rbf(points) | ||
| fit = rbf(*np.transpose(points), function='cubic') |
There was a problem hiding this comment.
New rbf() function requires another input format. The input list is transposed and then unpacked with *.
Old: [ [ x1, x2, ... , xd, val ] , [ ... ] , ... ]
New: [ x1, ... ] , [ x2, ... ] , ... , [ xd, ... ] , [ val, ... ]
Original function included cubic basis function, so now it's called manually in arguments.
|
Thanks! I'm actually getting different answers with new and old RBF. Any idea why? points = np.array([[0., 0., 1.], [0., 1., 1.], [1., 0., 1.], [1., 1., 1.], [0.5, 0.5, 0.]])
test_point = [0.3, 0.3]
old_fit = rbf_old(points)
print(old_fit(test_point))
new_fit = rbf(*np.transpose(points), function='cubic')
print(new_fit(*test_point)) |
|
It looks like you have an additional polynomial bt x + a in the interpolation function https://arxiv.org/pdf/1605.00998.pdf (equation 4) while scipy uses only the first "sum-lambda-phi" term by default:
I'm pretty sure it's true, cause I coded my own rbf without extra terms and get exactly the same results as I get in the standard library. |
The rbf() function is now called from standard scipy library.