| Author |
Comment/Response |
toen
|
04/09/12 09:35am
Hi all,
I'd like to convolve an interpolated function with a Gaussian kernel, but Mathematica (8.0) does not approve. The following example should give the flavour of what I'm after:
Say you've got some data points:
randTab=Table[{x+RandomReal[x (1-x)/4],RandomReal[]},{x,0,1,0.1}]
note that the x-ordinate is not nicely distributed (which makes ListConvolve and DiscreteConvolve not useable). But still Mathematica can interpolate some polynomials through them:
Show[ListPlot[randTab], Plot[Interpolation[randTab][t], {t, 0, 1}]]
Now I'd like the blurred function to converge on the end data points, so it's easiest to define the function outside the 0≤t≤1 domain:
q[t_]:=Piecewise[{{randTab[[1,2]],t<0},{Interpolation[randTab][t],0<= t<= 1},{randTab[[-1,2]],1<t}}]
and Plot[q[t], {t, -1, 2}] shows that all is as I want it, except for some odd gaps in the graphic between the piecewise defined curves at t=0 and t=1. Presuming this is some bug in the display code,and not in the function definition, I continue:
Convolve[PDF[NormalDistribution[0, 1], s], q[s], s, t]
and get nothing. So what's the problem? In contrast
r[t_]:=Piecewise[{{0,t<0},{t^2,0<= t<= 1},{1,1<t}}];
Convolve[PDF[NormalDistribution[0, 1], s], r[s], s, t]
works fine. So Mathematica is fine at convolving Gaussian kernels across polynomial-piecewise-defined functions, but not polynomial interpolating functions?
/toen
URL: , |
|