Consider the following example:
Module[{lst, iFn0},
lst = {{5, 1}, {7, 4}, {12, 5}};
iFn0 = Interpolation[lst, InterpolationOrder -> 0];
iFn0[5.25]
];
This returns 4. Obviously, interpolation has been constructed by "pulling back" the values, as if to say that the correct value for everything up to 7 is the measurement at 7.
But I would like to construct an interpolation by "pushing forward" the values, so that the correct value in the closed-open interval [5, 7) is 1. I know that I can cycle the values forward in lst and sort of fake the outcome:
`lst2 = {{5, 1}, {7, 1}, {12, 4}, {12.01, 5}}`
But this is problematic, because then iFn0[7] = 1 and I need it to be 4.
Is there a setting for InterpolationOrder -> 0 that will do the interpolation in the desired way?
yvalues one position to the right, and double up the value on the left end.slideValues[pts_] := Module[{yvals = RotateRight[pts[[All, 2]]]}, yvals[[1]] = yvals[[2]]; Interpolation[Transpose[{pts[[All, 1]], yvals}], InterpolationOrder -> 0]]– Daniel Lichtblau Jun 05 '15 at 21:51