Does anyone know why I can't seem to get a second derivative of this interpolating function f? In this example, h[x] is zero for all x.

data = Join[RandomVariate[NormalDistribution[-3, 1], 100], RandomVariate[NormalDistribution[3, 1], 100]];
f = PDF[SmoothKernelDistribution[data]];
g = f';
h = g';
Plot[{f[x], g[x], h[x]}, {x, -10, 10}, PlotRange -> All]

enter image description here

  • 1
    $\begingroup$ You might try KernelMixtureDistribution to avoid the piecewise linear limitation $\endgroup$
    – Andy Ross
    May 2 '15 at 2:01

If you plot f, f', and f'' over a much smaller range, the answer will be obvious: the interpolation function f is piecewise linear, f' is piecewise constant (i.e., a step function), and f'' is identically zero within each interval.

  • $\begingroup$ Oops, I backspaced in the window and the message got messed up. $\endgroup$
    – user15994
    May 1 '15 at 21:35

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.