6
$\begingroup$

I have two sensors that measure speed $v(t)$ of a moving vehicle. The first sensor produces a signal $f(t)$ which is a very accurate estimation of speed. However, it only works for slow to moderate speeds and beyond a certain limit, it simply fails to report anything. Let's assume we can model this behavior with an additional output of this sensor using signal $h(t)$, which is $1$ while $f(t)$ is valid and is $0$ when $f(t)$ is invalid.

Now, the second sensor produces signal $g(t)$ for all speeds but it is not particularly accurate. When $h(t)$ is 1, i.e. when speed is low and the first sensor produces perfect results via $f(t)$, the signal from the second sensor could be modeled as:

Equation 1: $g(t) = \beta_{0}(t) + \beta_{1}(t)v(t) + \epsilon$

The parameters for this linear relationship, $\beta_{0}$ and $\beta_{1}$ are unknown. All we know is that they vary very slowly over time.

So the problem is to estimate $v(t)$ given the 3 signals $f,h,g$.

One solution is of course to forget about $g(t)$ and just report the last value of $f(t)$ when it becomes invalid. Effectively, it means to saturate the output at a certain high speed.

Alternatively, my initial idea was to use a form of rolling linear regression to estimate the $\beta$ parameters with a fixed window size $w$: When $h(t)$ is $1$, I simply report $f(t)$ and update $\beta_{0}$ and $\beta_{1}$. When it is $0$, I report a $\hat{v}(t)$ estimated using $g(t)$ and the last calculated $\beta$ coefficients. This is obviously very slow since I have to solve a linear regression at each sample.

Questions:

(1) Does the idea of using rolling linear regression make sense? If yes, how can I do it fast?

(2) Would it be possible to something like a Kalman filter to solve this problem? I'm not sure how to express this problem in a linear state-space model.

(3) I guess the most challenging question would be what to do in the case that $f(t)$ is quantized (e.g. an integer value) while $v(t)$ and $g(t)$ are not. I guess we might be able to simulate it by assuming a uniform distribution for $\epsilon$ in equation 1.

$\endgroup$
5
  • 1
    $\begingroup$ Welcome to dsp.SE. Great question. I need to think about it a bit. $\endgroup$
    – Jason R
    Commented Oct 18, 2012 at 14:02
  • $\begingroup$ Thinking aloud about your initial idea: Is this to be implemented as a real time system, say on a microcontroller? If not, then linear regression shouldn't be a big deal because it's just a matrix operation. $\endgroup$
    – Atul Ingle
    Commented Oct 18, 2012 at 17:35
  • $\begingroup$ @AtulIngle You guessed right. I wonder if there is a way to implement a fast rolling regression that would do it incrementally rather than repeating all of the matrix operation for each sample. $\endgroup$
    – AlefSin
    Commented Oct 18, 2012 at 18:27
  • $\begingroup$ Can you supply us some data to play around with the problem? $\endgroup$ Commented Oct 19, 2012 at 10:49
  • $\begingroup$ @Andrey I'll prepare an example dataset and post it later; though I have only real data recorded from the difficult version of the problem, i.e. for the case that $f(t)$ is quantized and reported as integer values. $\endgroup$
    – AlefSin
    Commented Oct 19, 2012 at 12:16

1 Answer 1

1
$\begingroup$

In response to your question (1):

Thinking along the lines of your initial idea, there is a way to avoid regression and do the following approximate procedure instead:

Without loss of generality, assume that $\epsilon$ has zero mean (if not, then just absorb it into the constant $\beta_0$). Also assume it is i.i.d and has finite variance. Suppose you obtain two sets of data for $(f,g)$ pairs when $h=1$. I will denote these as $\{(f_{1,i}, g_{1,i})\}_{i=1}^N$ and $\{(f_{2,i}, g_{2,i})\}_{i=1}^N$.

Let $\bar{f_1} = \frac{1}{N} \sum_{i=1}^N f_{1,i}$ and similarly define $\bar{g}_1$, $\bar{f}_2$ and $\bar{g}_2$. If $N$ is sufficiently large, we can now claim that, at least approximately, the noise $\epsilon$ can be averaged out and we can write: $$ \bar{g}_1 \approx \beta_0 + \beta_1 \bar{f_1} $$ and $$ \bar{g}_2 \approx \beta_0 + \beta_1 \bar{f_2}. $$ Now we only need to solve two equations in two unknowns to get the scale parameter $\beta_1$ and offset $\beta_0$, provided $|\bar{f}_1 - \bar{f}_2|>0$.

Of course, whether this will work in your application will depend on whether the variance of $\epsilon$ is small enough (remember: averaging will reduce the variance by a factor of $1/N$), and whether the $f$'s are really noise free when $h=1$.

In response to question (3):

The same procedure should work in case $f$ is a quantized version of the true velocity. The argument here is that quantization introduces a small amount of noise that is approximately uniformly distributed with zero mean. It gets averaged out for large $N$, or so I hope.

$\endgroup$
2
  • $\begingroup$ That's an interesting idea though one should be careful how the two sets of data are collected. A simplistic approach like e.g. separating the even and odd numbered samples would not work as $E\{\bar{f_1}\}$ and $E\{\bar{f_2}\}$ would be the same for large $N$. $\endgroup$
    – AlefSin
    Commented Oct 19, 2012 at 12:11
  • $\begingroup$ You are right. Also consider a situation where the velocity just stays constant in the $h=1$ regime. Then the two equations are essentially identical (with slightly perturbed coefficients, due to noise). For such cases, we can introduce a safeguard by checking the difference $|\bar{f}_1 - \bar{f}_2|$ and solving the linear system only if this difference is non-zero (or above a certain threshold). I have edited my answer to include this check in the procedure. $\endgroup$
    – Atul Ingle
    Commented Oct 19, 2012 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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