0
$\begingroup$

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];

enter image description here 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?

$\endgroup$
  • 2
    $\begingroup$ Interpolation[data, Method -> "Spline"]? $\endgroup$ – happy fish Mar 13 '17 at 11:47
  • $\begingroup$ have a look at 15879 $\endgroup$ – happy fish Mar 13 '17 at 11:52
  • 2
    $\begingroup$ You can take derivatives with that function, and you can get a BSplineFunction with explicit parameters, what else do you want? $\endgroup$ – happy fish Mar 13 '17 at 12:24
  • $\begingroup$ The suggestion of @happyfish works for me: i.stack.imgur.com/3horZ.png $\endgroup$ – Michael E2 Mar 13 '17 at 12:33
  • 1
    $\begingroup$ 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 $\endgroup$ – george2079 Mar 13 '17 at 15:18
2
$\begingroup$

This is where a monotonic interpolation method like Steffen's interpolation or Fritsch-Carlson interpolation is useful. Using the routine from this answer:

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

Plot[k[x, 0], {x, -2, 2}]

monotonic interpolant

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.