On Wed, Apr 11, 2007 at 08:10:24PM -0400, James Turner wrote:
Hi Stefan,
Sorry for the slow reply to this.
Thanks for spotting that. When I fix those lines, I see:
[[ 3.9000001 3.0999999 2.0999999 1.10000002 1.89999998 2.9000001 ] [ 3.9000001 3.0999999 2.0999999 1.10000002 1.89999998 2.9000001 ]]
Actually, I think I made a mistake in my first post of 4 April, when I suggested the first value should be 3.9. I was thinking that the "reflect" mode just mirrors the input (like the "mirror" mode) and then interpolates the resulting values, in which case the first value would be 3.9 and the last would be 1.9 and 2.9. That seems to be what is now happening in your example above. However, I later realized that it is probably supposed to interpolate only within the bounds of the input data and *then* pad the output by "reflecting" the *interpolated* values in the way you describe below. What confused me was the extra 1.9 in the 2nd-last output column, but I think that is just the same problem (calculating one point too many) that I reported and you fixed for the "constant" mode, isn't it?
Yes, there is a fundamental problem with using "reflect" mode for interpolation. You have data points 4 3 2 1 | | | | so you can interpolate between the 4 and the 1. Now, when you use "reflect" mode, the data becomes: 1 2 3 4 4 3 2 1 1 2 3 4 | | | | This is where things become problematic. If we try to interpolate a point between the two 4's, we are going to get strange results because of the spline-fitting routine (you remember the problems with extrapolation we've had before). So, the easiest way to fix this is simply not to use reflect-mode, but to use mirror-mode instead. 1 2 3 4 3 2 1 2 3 4 | | | | This causes no problem, since, no matter where you interpolate, no extrapolation is done. I've enabled mirror-mode, and put in a warning whenever the user tries to interpolate using reflect-mode. There might still be a few minor indexing issues, but fixing them unfortunately won't alleviate this bigger design issue. To address this problem would entail extending the input dataset by the necessary number of elements (which depends on the order of interpolation), using the applicable mode (i.e. mirror, reflect etc.). Then, all indexing operations need to be adjusted accordingly. Since everything works at the moment when using mirror and constant mode, I'm not sure all that effort is warranted. Regards Stéfan