Clement LAUZIN
2011-Jun-01 13:24 UTC
[R] interpolation and extremum location of a surface
Hello, I have a x,y,z file.Z is not corresponding to a simple analytical function of x and y (see below). I am trying to find the minimum location of this surface and the z value corresponding to this location by a spline interpolation or from a polynomial fit. I tried with the akima package but as the location of the point I am looking for (the minimum) is outside of the convex hull it's not giving any answer. If someone has any idea or any suggestion? Thank you in advance Pierre x y z 4.1 60 -152.1719593 4.1 75 -171.136801 4.1 90 -170.4604774 4.2 60 -168.7745552 4.2 75 -174.9667333 4.2 90 -172.1853334 4.3 60 -173.7736418 4.3 75 -171.6712745 4.3 90 -167.6662458 4.05 60 -137.8379387 4.15 60 -162.2264066 4.25 60 -172.4453286 4.35 60 -173.2123715 4.05 67.5 -158.8239625 4.1 67.5 -167.314534 4.15 67.5 -172.586182 4.2 67.5 -175.2217594 4.25 67.5 -175.7162683 4.3 67.5 -174.4890566 4.35 67.5 -171.8940061 4.05 75 -165.4388778 4.15 75 -174.1460392 4.25 75 -174.022344 4.35 75 -168.2149168 4.05 82.5 -166.4026077 4.1 82.5 -170.9199652 4.15 82.5 -172.9923449 4.2 82.5 -173.0803255 4.25 82.5 -171.5739101 4.3 82.5 -168.8024715 4.35 82.5 -165.0431276 4.05 90 -166.2592978 4.15 90 -172.2861302 4.25 90 -170.5383652 4.35 90 -163.8389615
Hans W Borchers
2011-Jun-01 16:50 UTC
[R] interpolation and extremum location of a surface
Clement LAUZIN <lauzin <at> hotmail.com> writes:> Hello, > > Hello, > > I have a x,y,z file.Z is not corresponding to a simple analytical function > of x and y (see below). I am trying to find the minimum location of this > surface and the z value corresponding to this location by a spline > interpolation or from a polynomial fit. I tried with the akima package but > as the location of the point I am looking for (the minimum) is outside of > the convex hull it's not giving any answer. > If someone has any idea or any suggestion? > > Thank you in advance PierreAccording to a 2-dimensional barycentric Lagrange interpolation that I am implementing right now in R, the minimum appears to be at x0 = (4.230490, 68.52776); fval = -175.7959 I certainly would be interested to hear from other reasonable locations of a minimum, as this may be a good test case. -- Hans Werner> x y z > 4.1 60 -152.1719593 > [ ... ] > 4.35 90 -163.8389615 >
David Winsemius
2011-Jun-01 17:24 UTC
[R] interpolation and extremum location of a surface
On Jun 1, 2011, at 9:24 AM, Clement LAUZIN wrote:> > > Hello, > > I have a x,y,z file.Z is not corresponding to a simple analytical > function of x and y (see below). > I am trying to find the minimum location of this surface and the z > value corresponding to this location by a spline interpolation or > from a polynomial fit. > I tried with the akima package but as the location of the point I am > looking for (the minimum) is outside of the convex hull it's not > giving any answer.I do not think that is the reason akima::interp is failing. (For one thing the minimum is not outside the convex hull of x and y.) Note that the help page says that x and y cannot be collinear but yours appear to be so. > table(ZZ$x) 4.05 4.1 4.15 4.2 4.25 4.3 4.35 5 5 5 5 5 5 5 > table(ZZ$y) 60 67.5 75 82.5 90 7 7 7 7 7 I took a shot at jittering the x and y and reapplying interpp ... and ended up with what appeared to be useless junk. If you look at the data with contourplot you can see it would place the minimum at around z=-175 at x=4.24, y=67. However, the contourplot and associated help pages say there is no documentation for the algorithm used. contourplot(z ~ x + y, data=ZZ, at=seq(-140, -180 , by= -0.5), interp=TRUE)> If someone has any idea or any suggestion? > > Thank you in advance Pierre > > > x y z > 4.1 60 -152.1719593 > 4.1 75 -171.136801 > 4.1 90 -170.4604774 > 4.2 60 -168.7745552 > 4.2 75 -174.9667333 > 4.2 90 -172.1853334 > 4.3 60 -173.7736418 > 4.3 75 -171.6712745 > 4.3 90 -167.6662458 > 4.05 60 -137.8379387 > 4.15 60 -162.2264066 > 4.25 60 -172.4453286 > 4.35 60 -173.2123715 > 4.05 67.5 -158.8239625 > 4.1 67.5 -167.314534 > 4.15 67.5 -172.586182 > 4.2 67.5 -175.2217594 > 4.25 67.5 -175.7162683 > 4.3 67.5 -174.4890566 > 4.35 67.5 -171.8940061 > 4.05 75 -165.4388778 > 4.15 75 -174.1460392 > 4.25 75 -174.022344 > 4.35 75 -168.2149168 > 4.05 82.5 -166.4026077 > 4.1 82.5 -170.9199652 > 4.15 82.5 -172.9923449 > 4.2 82.5 -173.0803255 > 4.25 82.5 -171.5739101 > 4.3 82.5 -168.8024715 > 4.35 82.5 -165.0431276 > 4.05 90 -166.2592978 > 4.15 90 -172.2861302 > 4.25 90 -170.5383652 > 4.35 90 -163.8389615 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD West Hartford, CT