Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


samar
Posts:
7
Registered:
7/25/11


pchip with 2 variables
Posted:
Jan 16, 2013 1:37 PM


Dear Cédric,
I want tu use Pchip function to interpolate my 2dimensional data set. I'm actually using spline interpolation (with csapi function) but it doesn't work well. I think that Pchip will be better for my data set but I have no idea how to use it with 2 variables ( x1 and x2 are my variables they take their values over a given list and V=f(X1,X2) is the matrix that gives the value taken by f on each couple (x1,x2))
The second question can we have the result of pchip in PPFORM?
Thank you very much for you help!
"Cédric Louyot" <cedric.louyot@NOSPAMonera.fr> wrote in message <eee8cbc.3@webx.raydaftYaTP>... > In fact, I'm not having any problem with the pchip function. > Actually, it works real fine on the set of data I'm dealing with in > 2D. However I also have to work on a set of 3D data (that looks > really similar to the 2D set). Therefore, I try to understand the 2D > algorithm in details in order to build a pchip3d (or even a pchipnd) > function that could work on sets of data of the form: > z(x,y) = f(x,y) (or even z(x1, x2, ..., xn)) > > I've already tried the interp2 options ('linear','spline' and > 'cubic') but they don't yield satisfactory results with my data. > That's why I try to build a pchip3d function. > > Is there any chance it has already been done before by someone else ? > Do you know where I could find the Fritsch and Carlson paper ? I've > already looked for it in vain. > > Thanks, > > Cédric > > John D'Errico wrote: > > > > > > In article <eee8cbc.1@webx.raydaftYaTP>, > > "Cédric Louyot" <cedric.louyot@NOSPAMonera.fr> wrote: > > > >> I'm looking for a precision regarding the algorithm that the > > function > >> pchip uses. In particular, according to the MATLAB function > > reference > >> : > >> "The slopes at the xj are chosen in such a way that P(x) > > preserves > >> the shape of the data and respects monoticity." > >> > >> Could anybody explain to me what is hidden behing "in such a > way" > > ? > >> How does pchip computes the slopes at the xj ? > >> > >> Thanks for your help, > >> > >> Cédric > > > > From the comments, we see that pchip is derived from > > a nice paper by Fritsch and Carlson. > > > > % F. N. Fritsch and R. E. Carlson, "Monotone Piecewise Cubic > > % Interpolation", SIAM J. Numerical Analysis 17, 1980, 238246. > > > > The idea is you choose a decent set of estimates of the > > slopes at the knots. Then you test to see if they satisfy > > some approximation to the monotonicity constraints put > > forth in the F&C paper. > > > > These constraints form a boundary, one edge of which is > > elliptic, around the set of cubic segments. If the choice > > of slopes falls outside the set of monotone cubic segments, > > then you adjust the derivatives so this does not happen. > > Its a nice algorithm that runs quite quickly and does not > > require the solution of a set of simultaneous linear > > equations as a simple interpolating spline does. > > > > The disadvantages to pchip are > > > > 1. It results in a C1 interpolant. (Discontinuous second > > derivatives, whereas an interpolating cubic spline is C2.) > > This is rarely a problem, although I have seen cases where > > the second derivative discontinuities were a significant > > flaw. > > > > 2. Since pchip is designed to produce locally monotone > > interpolants, it sometimes produces less than desireable > > results on spiky data. (By locally monotone, I mean it > > does not introduce any extrema in the curve that is not > > already in the data.) > > > > What happens when you have a spike in your data? Pchip > > forces the derivative to zero at the maximum (or minimum) > > of the spike. Again, this is by design. > > > > Are you having problems with pchip? Very often this > > suggests that you may have data which is inappropriate > > for pchip. For example, I would not use pchip to > > interpolate an illuminant spectral power curve. > > Especially not for one derived from a fluorescent light. > > > > HTH, > > John D'Errico > > > > > >  > > There are no questions "?" about my real address. > > > > The best material model of a cat is another, or > > preferably the same, cat. > > A. Rosenblueth, Philosophy of Science, 1945 > >



