Why can I not interpolate even though the values are monotonically increasing?
up vote
0
down vote
favorite
I have 2 arrays that I plot this way:
plt.plot(x1, x2)
And I want to find out what are the values of x2
at x1=2,5,75,10,100, and 1000
. Since all values may not exist, I interpolate using this:
from scipy.interpolate import interp1d
f1=interp1d(x1, x2)
f2=interp1d(x1, x2, kind='cubic')
But f2
throws this error:
ValueError: Expect x to be a 1-D sorted array_like.
But the values are monotonically increasingly as expected by: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html
What am I doing wrong?
x1
array([1.00020004e+00, 1.00020004e+00, 1.00080064e+00, 1.00200401e+00,
1.00341160e+00, 1.00603622e+00, 1.01173614e+00, 1.02165917e+00,
1.02965404e+00, 1.04362346e+00, 1.05820106e+00, 1.07688994e+00,
1.10107906e+00, 1.12688754e+00, 1.16063138e+00, 1.19161106e+00,
1.23578843e+00, 1.29198966e+00, 1.35062129e+00, 1.42775557e+00,
1.52207002e+00, 1.63345312e+00, 1.77746178e+00, 1.93124759e+00,
2.11954218e+00, 2.37191651e+00, 2.68528464e+00, 2.97973778e+00,
3.38983051e+00, 3.89105058e+00, 4.48430493e+00, 5.31349628e+00,
6.28930818e+00, 7.59878419e+00, 9.38086304e+00, 1.20192308e+01,
1.57232704e+01, 2.06611570e+01, 2.68817204e+01, 3.49650350e+01,
4.58715596e+01, 6.57894737e+01, 8.92857143e+01, 1.38888889e+02,
2.27272727e+02, 4.16666667e+02, 1.00000000e+03, 2.50000000e+03,
2.50000000e+03, 5.00000000e+03])
x2
array([ 11.18083778, 12.00065196, 12.88057749, 13.82502193,
14.838716 , 15.92673731, 17.09453577, 18.34796088,
19.69329106, 21.13726508, 22.68711581, 24.35060647,
26.1360695 , 28.05244828, 30.10934199, 32.31705361,
34.68664159, 37.22997521, 39.95979405, 42.88977178,
46.0345847 , 49.40998519, 53.03288065, 56.9214182 ,
61.09507555, 65.57475857, 70.38290604, 75.54360201,
81.08269642, 87.02793465, 93.40909644, 100.25814508,
107.6093875 , 115.49964612, 123.96844331, 133.05819935,
142.81444487, 153.28604899, 164.52546404, 176.58898835,
189.53704818, 203.43450047, 218.35095766, 234.36113639,
251.54523176, 269.98931903, 289.78578477, 311.03378962,
333.83976499, 358.31794618])
python scipy interpolation
add a comment |
up vote
0
down vote
favorite
I have 2 arrays that I plot this way:
plt.plot(x1, x2)
And I want to find out what are the values of x2
at x1=2,5,75,10,100, and 1000
. Since all values may not exist, I interpolate using this:
from scipy.interpolate import interp1d
f1=interp1d(x1, x2)
f2=interp1d(x1, x2, kind='cubic')
But f2
throws this error:
ValueError: Expect x to be a 1-D sorted array_like.
But the values are monotonically increasingly as expected by: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html
What am I doing wrong?
x1
array([1.00020004e+00, 1.00020004e+00, 1.00080064e+00, 1.00200401e+00,
1.00341160e+00, 1.00603622e+00, 1.01173614e+00, 1.02165917e+00,
1.02965404e+00, 1.04362346e+00, 1.05820106e+00, 1.07688994e+00,
1.10107906e+00, 1.12688754e+00, 1.16063138e+00, 1.19161106e+00,
1.23578843e+00, 1.29198966e+00, 1.35062129e+00, 1.42775557e+00,
1.52207002e+00, 1.63345312e+00, 1.77746178e+00, 1.93124759e+00,
2.11954218e+00, 2.37191651e+00, 2.68528464e+00, 2.97973778e+00,
3.38983051e+00, 3.89105058e+00, 4.48430493e+00, 5.31349628e+00,
6.28930818e+00, 7.59878419e+00, 9.38086304e+00, 1.20192308e+01,
1.57232704e+01, 2.06611570e+01, 2.68817204e+01, 3.49650350e+01,
4.58715596e+01, 6.57894737e+01, 8.92857143e+01, 1.38888889e+02,
2.27272727e+02, 4.16666667e+02, 1.00000000e+03, 2.50000000e+03,
2.50000000e+03, 5.00000000e+03])
x2
array([ 11.18083778, 12.00065196, 12.88057749, 13.82502193,
14.838716 , 15.92673731, 17.09453577, 18.34796088,
19.69329106, 21.13726508, 22.68711581, 24.35060647,
26.1360695 , 28.05244828, 30.10934199, 32.31705361,
34.68664159, 37.22997521, 39.95979405, 42.88977178,
46.0345847 , 49.40998519, 53.03288065, 56.9214182 ,
61.09507555, 65.57475857, 70.38290604, 75.54360201,
81.08269642, 87.02793465, 93.40909644, 100.25814508,
107.6093875 , 115.49964612, 123.96844331, 133.05819935,
142.81444487, 153.28604899, 164.52546404, 176.58898835,
189.53704818, 203.43450047, 218.35095766, 234.36113639,
251.54523176, 269.98931903, 289.78578477, 311.03378962,
333.83976499, 358.31794618])
python scipy interpolation
is it possible that the splin cubic is not working because in x1 you have equal values (for example the two first ones)? from the doc it should make sens because of the way they interpolate
– Alexis
yesterday
The digits that we can see of the first two values ofx1
are the same. If those two values are actually the same, thenx1
is not strictly monotonically increasing.
– Warren Weckesser
yesterday
@WarrenWeckesser Agreed. I didn't notice them. And didn't make the distinction betweenmonotonically increasing
andstrictly monotonically increasing
. Is there an alternative method for my data?
– maximusdooku
yesterday
So you do have repeatedx1
values with differentx2
values? What do you expect an interpolator to do with such data? That is, what should the interpolator return at one of those repeated values ofx1
?
– Warren Weckesser
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have 2 arrays that I plot this way:
plt.plot(x1, x2)
And I want to find out what are the values of x2
at x1=2,5,75,10,100, and 1000
. Since all values may not exist, I interpolate using this:
from scipy.interpolate import interp1d
f1=interp1d(x1, x2)
f2=interp1d(x1, x2, kind='cubic')
But f2
throws this error:
ValueError: Expect x to be a 1-D sorted array_like.
But the values are monotonically increasingly as expected by: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html
What am I doing wrong?
x1
array([1.00020004e+00, 1.00020004e+00, 1.00080064e+00, 1.00200401e+00,
1.00341160e+00, 1.00603622e+00, 1.01173614e+00, 1.02165917e+00,
1.02965404e+00, 1.04362346e+00, 1.05820106e+00, 1.07688994e+00,
1.10107906e+00, 1.12688754e+00, 1.16063138e+00, 1.19161106e+00,
1.23578843e+00, 1.29198966e+00, 1.35062129e+00, 1.42775557e+00,
1.52207002e+00, 1.63345312e+00, 1.77746178e+00, 1.93124759e+00,
2.11954218e+00, 2.37191651e+00, 2.68528464e+00, 2.97973778e+00,
3.38983051e+00, 3.89105058e+00, 4.48430493e+00, 5.31349628e+00,
6.28930818e+00, 7.59878419e+00, 9.38086304e+00, 1.20192308e+01,
1.57232704e+01, 2.06611570e+01, 2.68817204e+01, 3.49650350e+01,
4.58715596e+01, 6.57894737e+01, 8.92857143e+01, 1.38888889e+02,
2.27272727e+02, 4.16666667e+02, 1.00000000e+03, 2.50000000e+03,
2.50000000e+03, 5.00000000e+03])
x2
array([ 11.18083778, 12.00065196, 12.88057749, 13.82502193,
14.838716 , 15.92673731, 17.09453577, 18.34796088,
19.69329106, 21.13726508, 22.68711581, 24.35060647,
26.1360695 , 28.05244828, 30.10934199, 32.31705361,
34.68664159, 37.22997521, 39.95979405, 42.88977178,
46.0345847 , 49.40998519, 53.03288065, 56.9214182 ,
61.09507555, 65.57475857, 70.38290604, 75.54360201,
81.08269642, 87.02793465, 93.40909644, 100.25814508,
107.6093875 , 115.49964612, 123.96844331, 133.05819935,
142.81444487, 153.28604899, 164.52546404, 176.58898835,
189.53704818, 203.43450047, 218.35095766, 234.36113639,
251.54523176, 269.98931903, 289.78578477, 311.03378962,
333.83976499, 358.31794618])
python scipy interpolation
I have 2 arrays that I plot this way:
plt.plot(x1, x2)
And I want to find out what are the values of x2
at x1=2,5,75,10,100, and 1000
. Since all values may not exist, I interpolate using this:
from scipy.interpolate import interp1d
f1=interp1d(x1, x2)
f2=interp1d(x1, x2, kind='cubic')
But f2
throws this error:
ValueError: Expect x to be a 1-D sorted array_like.
But the values are monotonically increasingly as expected by: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html
What am I doing wrong?
x1
array([1.00020004e+00, 1.00020004e+00, 1.00080064e+00, 1.00200401e+00,
1.00341160e+00, 1.00603622e+00, 1.01173614e+00, 1.02165917e+00,
1.02965404e+00, 1.04362346e+00, 1.05820106e+00, 1.07688994e+00,
1.10107906e+00, 1.12688754e+00, 1.16063138e+00, 1.19161106e+00,
1.23578843e+00, 1.29198966e+00, 1.35062129e+00, 1.42775557e+00,
1.52207002e+00, 1.63345312e+00, 1.77746178e+00, 1.93124759e+00,
2.11954218e+00, 2.37191651e+00, 2.68528464e+00, 2.97973778e+00,
3.38983051e+00, 3.89105058e+00, 4.48430493e+00, 5.31349628e+00,
6.28930818e+00, 7.59878419e+00, 9.38086304e+00, 1.20192308e+01,
1.57232704e+01, 2.06611570e+01, 2.68817204e+01, 3.49650350e+01,
4.58715596e+01, 6.57894737e+01, 8.92857143e+01, 1.38888889e+02,
2.27272727e+02, 4.16666667e+02, 1.00000000e+03, 2.50000000e+03,
2.50000000e+03, 5.00000000e+03])
x2
array([ 11.18083778, 12.00065196, 12.88057749, 13.82502193,
14.838716 , 15.92673731, 17.09453577, 18.34796088,
19.69329106, 21.13726508, 22.68711581, 24.35060647,
26.1360695 , 28.05244828, 30.10934199, 32.31705361,
34.68664159, 37.22997521, 39.95979405, 42.88977178,
46.0345847 , 49.40998519, 53.03288065, 56.9214182 ,
61.09507555, 65.57475857, 70.38290604, 75.54360201,
81.08269642, 87.02793465, 93.40909644, 100.25814508,
107.6093875 , 115.49964612, 123.96844331, 133.05819935,
142.81444487, 153.28604899, 164.52546404, 176.58898835,
189.53704818, 203.43450047, 218.35095766, 234.36113639,
251.54523176, 269.98931903, 289.78578477, 311.03378962,
333.83976499, 358.31794618])
python scipy interpolation
python scipy interpolation
asked yesterday
maximusdooku
1,35421343
1,35421343
is it possible that the splin cubic is not working because in x1 you have equal values (for example the two first ones)? from the doc it should make sens because of the way they interpolate
– Alexis
yesterday
The digits that we can see of the first two values ofx1
are the same. If those two values are actually the same, thenx1
is not strictly monotonically increasing.
– Warren Weckesser
yesterday
@WarrenWeckesser Agreed. I didn't notice them. And didn't make the distinction betweenmonotonically increasing
andstrictly monotonically increasing
. Is there an alternative method for my data?
– maximusdooku
yesterday
So you do have repeatedx1
values with differentx2
values? What do you expect an interpolator to do with such data? That is, what should the interpolator return at one of those repeated values ofx1
?
– Warren Weckesser
yesterday
add a comment |
is it possible that the splin cubic is not working because in x1 you have equal values (for example the two first ones)? from the doc it should make sens because of the way they interpolate
– Alexis
yesterday
The digits that we can see of the first two values ofx1
are the same. If those two values are actually the same, thenx1
is not strictly monotonically increasing.
– Warren Weckesser
yesterday
@WarrenWeckesser Agreed. I didn't notice them. And didn't make the distinction betweenmonotonically increasing
andstrictly monotonically increasing
. Is there an alternative method for my data?
– maximusdooku
yesterday
So you do have repeatedx1
values with differentx2
values? What do you expect an interpolator to do with such data? That is, what should the interpolator return at one of those repeated values ofx1
?
– Warren Weckesser
yesterday
is it possible that the splin cubic is not working because in x1 you have equal values (for example the two first ones)? from the doc it should make sens because of the way they interpolate
– Alexis
yesterday
is it possible that the splin cubic is not working because in x1 you have equal values (for example the two first ones)? from the doc it should make sens because of the way they interpolate
– Alexis
yesterday
The digits that we can see of the first two values of
x1
are the same. If those two values are actually the same, then x1
is not strictly monotonically increasing.– Warren Weckesser
yesterday
The digits that we can see of the first two values of
x1
are the same. If those two values are actually the same, then x1
is not strictly monotonically increasing.– Warren Weckesser
yesterday
@WarrenWeckesser Agreed. I didn't notice them. And didn't make the distinction between
monotonically increasing
and strictly monotonically increasing
. Is there an alternative method for my data?– maximusdooku
yesterday
@WarrenWeckesser Agreed. I didn't notice them. And didn't make the distinction between
monotonically increasing
and strictly monotonically increasing
. Is there an alternative method for my data?– maximusdooku
yesterday
So you do have repeated
x1
values with different x2
values? What do you expect an interpolator to do with such data? That is, what should the interpolator return at one of those repeated values of x1
?– Warren Weckesser
yesterday
So you do have repeated
x1
values with different x2
values? What do you expect an interpolator to do with such data? That is, what should the interpolator return at one of those repeated values of x1
?– Warren Weckesser
yesterday
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
The test it's doing it is:
np.any(x1[1:] <= x1[:-1])
notice the <=
, which means equal values (like: 2.50000000e+03,, 2.50000000e+03) in your array will cause errors.
Changing these and (there's two more at the start of the array) will make the error go away.
I not sure this is the right way to go about dealing with your data, but you could delete the dupes (and corresponding x2 values) with something like:
x3, ind = np.unique(x1, return_index = True)
x4 = x2[ind]
f2=interp1d(x3, x4, kind='cubic')
Thanks a lot! Unfortunately, I can't change these values itself, since they are a part of my computation. Is there an alternative interpolation technique for non-linear data that doesn't have this limitation.
– maximusdooku
yesterday
you can add/substract epsilon to the repeated values, it will not affect the results but they will no longer be equal
– Sembei Norimaki
yesterday
@SembeiNorimaki Could you please explain as an answer, please? I am not sure how to.
– maximusdooku
yesterday
It's not clear what should happen here when you have the same x1 corresponding to a different x2.
– Mark Meyer
yesterday
You could delete them @maximusdooku -- not sure if that's appropriate. See edit
– Mark Meyer
yesterday
|
show 1 more comment
up vote
0
down vote
Just add this two lines before doing the interpolation:
x1[0] -= 0.0000001
x1[-2] += 0.0000001
Looks like with epsilon does not work
This solution won't scale for me, as I will be doing this over thousands of arrays. And I don't know which indices will be repeated in advance.
– maximusdooku
yesterday
Then you will need to iterate over the values and when you see repeated ones apply this
– Sembei Norimaki
yesterday
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
The test it's doing it is:
np.any(x1[1:] <= x1[:-1])
notice the <=
, which means equal values (like: 2.50000000e+03,, 2.50000000e+03) in your array will cause errors.
Changing these and (there's two more at the start of the array) will make the error go away.
I not sure this is the right way to go about dealing with your data, but you could delete the dupes (and corresponding x2 values) with something like:
x3, ind = np.unique(x1, return_index = True)
x4 = x2[ind]
f2=interp1d(x3, x4, kind='cubic')
Thanks a lot! Unfortunately, I can't change these values itself, since they are a part of my computation. Is there an alternative interpolation technique for non-linear data that doesn't have this limitation.
– maximusdooku
yesterday
you can add/substract epsilon to the repeated values, it will not affect the results but they will no longer be equal
– Sembei Norimaki
yesterday
@SembeiNorimaki Could you please explain as an answer, please? I am not sure how to.
– maximusdooku
yesterday
It's not clear what should happen here when you have the same x1 corresponding to a different x2.
– Mark Meyer
yesterday
You could delete them @maximusdooku -- not sure if that's appropriate. See edit
– Mark Meyer
yesterday
|
show 1 more comment
up vote
1
down vote
The test it's doing it is:
np.any(x1[1:] <= x1[:-1])
notice the <=
, which means equal values (like: 2.50000000e+03,, 2.50000000e+03) in your array will cause errors.
Changing these and (there's two more at the start of the array) will make the error go away.
I not sure this is the right way to go about dealing with your data, but you could delete the dupes (and corresponding x2 values) with something like:
x3, ind = np.unique(x1, return_index = True)
x4 = x2[ind]
f2=interp1d(x3, x4, kind='cubic')
Thanks a lot! Unfortunately, I can't change these values itself, since they are a part of my computation. Is there an alternative interpolation technique for non-linear data that doesn't have this limitation.
– maximusdooku
yesterday
you can add/substract epsilon to the repeated values, it will not affect the results but they will no longer be equal
– Sembei Norimaki
yesterday
@SembeiNorimaki Could you please explain as an answer, please? I am not sure how to.
– maximusdooku
yesterday
It's not clear what should happen here when you have the same x1 corresponding to a different x2.
– Mark Meyer
yesterday
You could delete them @maximusdooku -- not sure if that's appropriate. See edit
– Mark Meyer
yesterday
|
show 1 more comment
up vote
1
down vote
up vote
1
down vote
The test it's doing it is:
np.any(x1[1:] <= x1[:-1])
notice the <=
, which means equal values (like: 2.50000000e+03,, 2.50000000e+03) in your array will cause errors.
Changing these and (there's two more at the start of the array) will make the error go away.
I not sure this is the right way to go about dealing with your data, but you could delete the dupes (and corresponding x2 values) with something like:
x3, ind = np.unique(x1, return_index = True)
x4 = x2[ind]
f2=interp1d(x3, x4, kind='cubic')
The test it's doing it is:
np.any(x1[1:] <= x1[:-1])
notice the <=
, which means equal values (like: 2.50000000e+03,, 2.50000000e+03) in your array will cause errors.
Changing these and (there's two more at the start of the array) will make the error go away.
I not sure this is the right way to go about dealing with your data, but you could delete the dupes (and corresponding x2 values) with something like:
x3, ind = np.unique(x1, return_index = True)
x4 = x2[ind]
f2=interp1d(x3, x4, kind='cubic')
edited yesterday
answered yesterday
Mark Meyer
29.6k32549
29.6k32549
Thanks a lot! Unfortunately, I can't change these values itself, since they are a part of my computation. Is there an alternative interpolation technique for non-linear data that doesn't have this limitation.
– maximusdooku
yesterday
you can add/substract epsilon to the repeated values, it will not affect the results but they will no longer be equal
– Sembei Norimaki
yesterday
@SembeiNorimaki Could you please explain as an answer, please? I am not sure how to.
– maximusdooku
yesterday
It's not clear what should happen here when you have the same x1 corresponding to a different x2.
– Mark Meyer
yesterday
You could delete them @maximusdooku -- not sure if that's appropriate. See edit
– Mark Meyer
yesterday
|
show 1 more comment
Thanks a lot! Unfortunately, I can't change these values itself, since they are a part of my computation. Is there an alternative interpolation technique for non-linear data that doesn't have this limitation.
– maximusdooku
yesterday
you can add/substract epsilon to the repeated values, it will not affect the results but they will no longer be equal
– Sembei Norimaki
yesterday
@SembeiNorimaki Could you please explain as an answer, please? I am not sure how to.
– maximusdooku
yesterday
It's not clear what should happen here when you have the same x1 corresponding to a different x2.
– Mark Meyer
yesterday
You could delete them @maximusdooku -- not sure if that's appropriate. See edit
– Mark Meyer
yesterday
Thanks a lot! Unfortunately, I can't change these values itself, since they are a part of my computation. Is there an alternative interpolation technique for non-linear data that doesn't have this limitation.
– maximusdooku
yesterday
Thanks a lot! Unfortunately, I can't change these values itself, since they are a part of my computation. Is there an alternative interpolation technique for non-linear data that doesn't have this limitation.
– maximusdooku
yesterday
you can add/substract epsilon to the repeated values, it will not affect the results but they will no longer be equal
– Sembei Norimaki
yesterday
you can add/substract epsilon to the repeated values, it will not affect the results but they will no longer be equal
– Sembei Norimaki
yesterday
@SembeiNorimaki Could you please explain as an answer, please? I am not sure how to.
– maximusdooku
yesterday
@SembeiNorimaki Could you please explain as an answer, please? I am not sure how to.
– maximusdooku
yesterday
It's not clear what should happen here when you have the same x1 corresponding to a different x2.
– Mark Meyer
yesterday
It's not clear what should happen here when you have the same x1 corresponding to a different x2.
– Mark Meyer
yesterday
You could delete them @maximusdooku -- not sure if that's appropriate. See edit
– Mark Meyer
yesterday
You could delete them @maximusdooku -- not sure if that's appropriate. See edit
– Mark Meyer
yesterday
|
show 1 more comment
up vote
0
down vote
Just add this two lines before doing the interpolation:
x1[0] -= 0.0000001
x1[-2] += 0.0000001
Looks like with epsilon does not work
This solution won't scale for me, as I will be doing this over thousands of arrays. And I don't know which indices will be repeated in advance.
– maximusdooku
yesterday
Then you will need to iterate over the values and when you see repeated ones apply this
– Sembei Norimaki
yesterday
add a comment |
up vote
0
down vote
Just add this two lines before doing the interpolation:
x1[0] -= 0.0000001
x1[-2] += 0.0000001
Looks like with epsilon does not work
This solution won't scale for me, as I will be doing this over thousands of arrays. And I don't know which indices will be repeated in advance.
– maximusdooku
yesterday
Then you will need to iterate over the values and when you see repeated ones apply this
– Sembei Norimaki
yesterday
add a comment |
up vote
0
down vote
up vote
0
down vote
Just add this two lines before doing the interpolation:
x1[0] -= 0.0000001
x1[-2] += 0.0000001
Looks like with epsilon does not work
Just add this two lines before doing the interpolation:
x1[0] -= 0.0000001
x1[-2] += 0.0000001
Looks like with epsilon does not work
edited yesterday
answered yesterday
Sembei Norimaki
2,371927
2,371927
This solution won't scale for me, as I will be doing this over thousands of arrays. And I don't know which indices will be repeated in advance.
– maximusdooku
yesterday
Then you will need to iterate over the values and when you see repeated ones apply this
– Sembei Norimaki
yesterday
add a comment |
This solution won't scale for me, as I will be doing this over thousands of arrays. And I don't know which indices will be repeated in advance.
– maximusdooku
yesterday
Then you will need to iterate over the values and when you see repeated ones apply this
– Sembei Norimaki
yesterday
This solution won't scale for me, as I will be doing this over thousands of arrays. And I don't know which indices will be repeated in advance.
– maximusdooku
yesterday
This solution won't scale for me, as I will be doing this over thousands of arrays. And I don't know which indices will be repeated in advance.
– maximusdooku
yesterday
Then you will need to iterate over the values and when you see repeated ones apply this
– Sembei Norimaki
yesterday
Then you will need to iterate over the values and when you see repeated ones apply this
– Sembei Norimaki
yesterday
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417102%2fwhy-can-i-not-interpolate-even-though-the-values-are-monotonically-increasing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
is it possible that the splin cubic is not working because in x1 you have equal values (for example the two first ones)? from the doc it should make sens because of the way they interpolate
– Alexis
yesterday
The digits that we can see of the first two values of
x1
are the same. If those two values are actually the same, thenx1
is not strictly monotonically increasing.– Warren Weckesser
yesterday
@WarrenWeckesser Agreed. I didn't notice them. And didn't make the distinction between
monotonically increasing
andstrictly monotonically increasing
. Is there an alternative method for my data?– maximusdooku
yesterday
So you do have repeated
x1
values with differentx2
values? What do you expect an interpolator to do with such data? That is, what should the interpolator return at one of those repeated values ofx1
?– Warren Weckesser
yesterday