I have the following problem statement which I have no idea how to approach,

I have a IR depth sensor, that produces a distribution for it's depth value. So it kind of looks something like this:

enter image description here

As you can see, it shows that there are two possibilities, one at 10 and one at 20. Taking the expectation of this will give me the real depth.

What i want to do is apply some signal processing to model the motion of this camera in the Z axis. Basically i want it to shift say 5m and spread out to represent the increasing uncertainity. Hopefully to look something like this

enter image description here

I guess for the spreading out part, applying a 1D gaussian convolution would work, but i am not sure about the timeshifting part. Can i convolve the signal below with another signal to actual timeshift it somehow?


yes, you can convolve with $\delta[n - n_o]$ to delay your signal by $n_o$ samples.

I am guessing you know how to represent $\delta[n]$ in MATLAB. And for spreading the signal, you can do by time scaling as $x_{spread}[n] = x[\frac{n}{M}]$. So, basically, the overall operation becomes:$$x_{final}[n] = x[\frac{n}{M} - n_o]$$

In MATLAB you can simulate this by following code:

x = sin(2*pi*(0:0.01:1));
y = sin(2*pi*(0-0.1:0.005:1-0.1));
plot(x);hold on;plot(y);

Here, time-spread is by a factor of $2$ after shifting the signal by $10$ samples.


  • $\begingroup$ this only works for sin/cos waves right, and not arbitary signals? $\endgroup$ – raaj Apr 23 '20 at 19:40
  • $\begingroup$ @raaj Why do you think so? It will work for all arbitrary input. $\endgroup$ – DSP Rookie Apr 23 '20 at 19:41
  • $\begingroup$ oh ok. are you able to provide a matlab code example that shows the convolution with 𝛿[𝑛−𝑛𝑜] t? $\endgroup$ – raaj Apr 23 '20 at 19:41
  • $\begingroup$ @raaj Create a vector of zeros of length equal to length of input, and then replace 0 by a 1 at the position by which you want to delay the input. When you convolve with this, it will represent convolving time delay $\delta[n]$. $\endgroup$ – DSP Rookie Apr 23 '20 at 19:44
  • $\begingroup$ another question..what if my original distribution was quantized only by 64 depth values. But i want to shift it by 1/2 a depth value. Is this actually feasable without upscaling the original distribution? $\endgroup$ – raaj Apr 23 '20 at 20:19

This requires a system with an LTI response like $\delta (n - N_o)$ combined with scaling. You would also want to model the spread as a function of the displacement along the z axis I suppose, so for ex: if the displacement along Z axis is $N_o$ samples then the spread should be given a function $f(N_o)$.

A good approximation rule would be $$f(N_o) =\sigma \sqrt{\frac{N_o}{M\sigma^2}}\tag{ standard deviation of shifted gaussian}$$ That means as the distance increases relative to variance of the original gaussian the standard deviation of new gaussian increases with the above relation. So when $N_o = M\sigma^2$ the standard deviation of new gaussian is increased by $\sigma$.

The parameter $M$ would depend on the problem and the specific requirements of the system modelling.

  • $\begingroup$ where did you get that equation for the SD of the shifted gaussian? $\endgroup$ – raaj Apr 23 '20 at 20:16
  • $\begingroup$ So just to be clear, say if my signal actually is univariate gaussian with a sigma of say 0.5. And i want it to spread to a sigma of 1.0, What kind of kernel should i be generating to convolve with? $\endgroup$ – raaj Apr 23 '20 at 20:43
  • 1
    $\begingroup$ @raaj Convolution of two gaussian with variance $\sigma_1^2$ and $\sigma_2^2$ gives a gausian with variance $\sigma_1^2 + \sigma_2^2$, you can do the math now. I have given you the above formula because I thought it makes sense to change the variance as a function of distance on z axis $\endgroup$ – Dsp guy sam Apr 23 '20 at 20:54
  • $\begingroup$ Use a gausian kernel with the variance as I defined in my answer and convolve this delayed gausian with the original signal...you have the required output $\endgroup$ – Dsp guy sam Apr 23 '20 at 20:59

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.