# Interpolating a function with splines

I would like to interpolate the following function

 g[z_, e_] :=
PDF[TruncatedDistribution[{e - 2, e + 2},
NormalDistribution[e, 0.3]], z]

a1 = N[g[-2, 0]];
a2 = N[g[-1, 0]];
a3 = N[g[0, 0]];
a4 = N[g[1, 0]];
a5 = N[g[2, 0]];


With your help I am now using:

 k[x_, e_] =
Interpolation[{{-2 + e, a1}, {-1 + e, a2},  {0 + e,
a3}, {1 + e, a4}, {2 + e, a5}},
Method -> "Spline"] [x];


I need e as an variable, which I can easily access. Can i somehow get rid of the error shown in the picture? Or do I have to stick to InterpolatingPolynomial? Can i somehow abuse InterpolatingFunction?

Why do i get negative values in the approximation function? Can i get rif of them with other, better methods?

• Interpolation[data, Method -> "Spline"]? – happy fish Mar 13 '17 at 11:47
• have a look at 15879 – happy fish Mar 13 '17 at 11:52
• You can take derivatives with that function, and you can get a BSplineFunction with explicit parameters, what else do you want? – happy fish Mar 13 '17 at 12:24
• The suggestion of @happyfish works for me: i.stack.imgur.com/3horZ.png – Michael E2 Mar 13 '17 at 12:33
• as to why you get negative values, its because you are doing a polynomial interpolation of something that's not a polynomial, with far too few points. You might have a look at FunctionInterpolation, or set InterpolationOrder->1 – george2079 Mar 13 '17 at 15:18

k[x_, e_] := SteffenInterpolation[{{-2 + e, a1}, {-1 + e, a2}, {0 + e, a3},