Convolution of horizontal shifted gaussian and heaveside funtion
LausX
Dear All,
I'm trying to undersatand the convolution operation in Igor.
For this I like to convolute a gaussian and a heavyside function for simplicity.
Both function are centered at t_0. If I set t_0 = 0, everything is fine. If t_0 is <> 0. the convoluted function is shifted by t_0. I read several posts about convolution but I couldnt find a working solution.
In the end I like to use this for a fitting procedure where I have to estimate also t_0.
Here is my example code:
Function testConv(t0)
Variable t0
Variable tp = 0.37
Variable Nmax = 1E3 + 1
Variable tmin = -20*tp
Variable tmax = -tmin
Variable dT = (tmax - tmin) / Nmax
Make/N=(Nmax)/D/O wGauss, xw, y_theta
SetScale/P x, tmin, dT, wGauss, xw, y_theta
xw = x
Variable const = 2*sqrt(2*ln(2))
wGauss = gauss(x, t0, tp/const)
Variable a = sum(wGauss)
wGauss /= a
y_theta = xw[p] > t0 ? 0 : 1
Duplicate/O y_theta, yw_conv
Convolve/A wGauss, yw_conv
return 0
End
Variable t0
Variable tp = 0.37
Variable Nmax = 1E3 + 1
Variable tmin = -20*tp
Variable tmax = -tmin
Variable dT = (tmax - tmin) / Nmax
Make/N=(Nmax)/D/O wGauss, xw, y_theta
SetScale/P x, tmin, dT, wGauss, xw, y_theta
xw = x
Variable const = 2*sqrt(2*ln(2))
wGauss = gauss(x, t0, tp/const)
Variable a = sum(wGauss)
wGauss /= a
y_theta = xw[p] > t0 ? 0 : 1
Duplicate/O y_theta, yw_conv
Convolve/A wGauss, yw_conv
return 0
End
Thank you for your suggestions
You offset both the Gaussian and the step function. Instead of this:
wGauss = gauss(x, t0, tp/const)
try this:
wGauss = gauss(x, 0, tp/const)
My suspicion is that will give you what you are expecting.
January 28, 2020 at 12:24 pm - Permalink