# Interpolation of a multivariate function with duplicated 2D abscissa points

I want to interpolate a function q[a,b] I have a data file which has the form {a,b,q} a sample is following

{{0.51, 0., 0.},
{0.51, 1.041808672472127, 4.895298538040123},
{0.51, 7.851696289441842, 17.70166883635361},
{0.51, 160.22124553764897, 0.0036047722229149396},
{1., 0., 0.},
{1., 0.0408552420577305, 0.19197249168784813},
{1., 0.30790965840948425, 0.6941830916217107},
{1., 6.2831860995156505, 0.0001413636165848997},
{1.49, 0., 0.},
{1.49, 0.030744601346473967, 0.14446414778529987},
{1.49, 4.699877937621654, 0.13709572480365165},
{1.49, 4.728256206201172, 0.00010637969126843464},
{1.98, 0., 0.},
{1.98, 0.027328844349427832, 0.1284140316020065},
{1.98, 4.177716639454909, 0.121864248031978},
{1.98, 4.202942053054388, 0.00009456079758043966}}


when I import this file and interpolate it gives error

Interpolation::indp: "There are duplicated abscissa points in {{0.51,0.},{0.51,1.041808672472127}"


Any Idea how to interpolate such data file having repetitive abscissa

• If you take a look at Interpolation documentation you will see that your input is wrong. q = {{#, #2}, #3} & @@@ data // Interpolation
– Kuba
Jan 12 '16 at 12:44
• @Kuba, actually in this case isn't it the documentation that is wrong? You can use data // Interpolation without any problem Jan 12 '16 at 13:05
• Of course, I do get the message that you will not get decent interpolation because the data isn't on a rectangular grid Jan 12 '16 at 13:06
• @JasonB You are supposed to be able to do so, but then I'd expect interpolation function domain to be [1-Length@data] and values which are those sublists. The fact it gives the same answer that mine is surprising. Btw, from the error message given by OP it seems that only two columns are provided to Interpolation and that's why the error occurs.
– Kuba
Jan 12 '16 at 13:13
• @Kuba, I've always used Interpolation this way (I didn't bother to read the documentation first). So if you do Interpolation[ {{x1,y1,z1},{x2,y2,z2}....}] then you get the exact same function as if you did Interpolation[ {{{x1,y1},z1},{{x2,y2},z2}....}]. Don't have old versions lying around to check how far back this behavior goes though. Jan 12 '16 at 13:24

Use GatherBy to gather all points with the same abscissa coordinates and then take the Mean of all those points.

Interpolation[
Map[
{#[[1, 1]], Mean[#[[All, 2]]]} &,
GatherBy[{{#1, #2}, #3} & @@@ data, First]
]
, InterpolationOrder -> 1
]

• It can be done by discrete data set. but interpolation order is more than 1 cannot be used. in interpolation order 1 I get the curve which is not smooth.
– Anna
Jan 13 '16 at 7:26
• Interpolation on unstructured grids is currently only supported with InterpolationOrder->1. Make the abscissa q grid and you can go for higher orders. Read the documentation. Jan 13 '16 at 7:41
• If smoothness is a requirement, please edit your questions and say that explicitly. Jan 13 '16 at 7:43