-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added scipy RBF interpolation #21
base: master
Are you sure you want to change the base?
Conversation
Added scipy RBF interpolation
@@ -168,53 +169,3 @@ def rseq(n, d): | |||
points = np.array([(0.5 + alpha*(i+1)) % 1 for i in range(n)]) | |||
|
|||
return points | |||
|
|||
|
|||
def rbf(points): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old rbf() function is completely removed.
@@ -2,6 +2,7 @@ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import Rbf() function from scipy as rbf().
@@ -116,7 +117,7 @@ def cubetobox(x): | |||
str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + ' ...') | |||
|
|||
# sampling next batch of points | |||
fit = rbf(points) | |||
fit = rbf(*np.transpose(points), function='cubic') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.