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)


enter image description here



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])









share|improve this question






















  • 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












  • @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















up vote
0
down vote

favorite












I have 2 arrays that I plot this way:



plt.plot(x1, x2)


enter image description here



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])









share|improve this question






















  • 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












  • @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













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)


enter image description here



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])









share|improve this question













I have 2 arrays that I plot this way:



plt.plot(x1, x2)


enter image description here



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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












  • 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


















  • 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












  • @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
















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












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')





share|improve this answer























  • 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


















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






share|improve this answer























  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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

























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')





share|improve this answer























  • 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















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')





share|improve this answer























  • 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













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')





share|improve this answer














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')






share|improve this answer














share|improve this answer



share|improve this answer








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


















  • 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












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






share|improve this answer























  • 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















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






share|improve this answer























  • 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













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






share|improve this answer














Just add this two lines before doing the interpolation:



x1[0] -= 0.0000001
x1[-2] += 0.0000001


Looks like with epsilon does not work







share|improve this answer














share|improve this answer



share|improve this answer








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


















  • 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


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

Alexandru Averescu

Trompette piccolo