Say I have two non-periodic signals, $f_1(t)$ and $f_2(t)$, with Fourier transforms $F_1(\omega)$ and $F_2(\omega)$. Basically, I need to line up $f_1(t)$ and $f_2(t)$ as close as possible, and I am allowed to shift the signals in time and multiply their Fourier transforms by a constant phase.

What is the most efficient method to find the values of the phase shift $\Delta \phi$ and the time delay $\Delta t$ such that, when the Fourier transform of $f_2$ is modified into

$$ F_2(\omega) e^{i (\Delta \phi + \omega \Delta t)}, $$

the modified $f_2$ best "lines up" with $f_1$ according to their cross-correlation (or some other measurement)?

I am interested in simple and computationally efficient methods, even if they are not necessarily perfect.


2 Answers 2


A pure time delay could be determined by looking for a peak in the cross correlation. But in your case $f2$ might also have an overall phase offset.

You could try to compute two cross correlations:

$$ \begin{align} x &= cross(f1,f2) \\ y &= cross(f1,hilbert(f2)) \\ \end{align} $$

where $hilbert(f2)$ refers to an overall 90° phase shifted version of $f2$. If you combine those two like this

$$ z = \sqrt{x^2 + y^2} $$

you should get something that is independent of the phase shift and shows you a peak at the correct time delay $\Delta t$. The "phase" at that peak, $atan2(y,x)$ should give you the phase offset $\Delta\phi$.

I don't know if such a problem is usually solved this way and I have not tried it myself. But it might work.

  • $\begingroup$ I used your method on some test cases and while it gives approximately correct answers, it wasn't perfect. $\endgroup$
    – ursus432
    Oct 4, 2017 at 11:54
  • $\begingroup$ Cool! This​ could be a starting point to a nonlinear optimization. It's really a nonlinear least squares problem if you want to minimize the sum of squared errors. $\endgroup$
    – sellibitze
    Oct 4, 2017 at 11:57
  • 1
    $\begingroup$ However, inspired by your approach, I did the following and it worked perfectly: Define the complex-valued signal $\tilde{f}_i = f_i + i \text{hilbert}(f_i)$, and then compute the (complex-valued) cross correlation of the two complex signals: $\text{cross}(\tilde{f}_1, \tilde{f}_2)$. The position of the peak of the amplitude of this complex vector identifies $\Delta t$, and the phase of the value at the peak is $\Delta \phi$. $\endgroup$
    – ursus432
    Oct 4, 2017 at 11:58
  • $\begingroup$ Yeah, I was scared of getting into nonlinear optimization because like I said, the method needed to be quick and simple. Fortunately the trick with the complex signals worked fine. $\endgroup$
    – ursus432
    Oct 4, 2017 at 12:02
  • 1
    $\begingroup$ Note that from the properties of the cross correlation, we have that $\text{cross}(\tilde{f}_1, \tilde{f}_2) \neq x + i y$, so the methods are actually different. There are extra terms on the left side. I'm not exactly sure of the theory behind this. $\endgroup$
    – ursus432
    Oct 4, 2017 at 12:10

Am I missing something obvious here?

Restating the problem:

Suppose that

$$ H(x) = G(x) e^{i(a + bx)} $$

where $H,G$ are known complex valued functions for a set of $x$ values and $ a,b,x $ are real values. Find $a,b$.

$$ i( a + bx ) = \ln( H(x) / G(x) ) $$

$$ i( a + bx ) = \ln( \| H(x) / G(x) \| ) + i \arg( H(x) / G(x) ) $$

The real part should be zero. Otherwise the best fit assumption is inaccurate. Disregard any non-zero values. If they are large, the fit is not good.

$$ a + bx = \arg( H(x) / G(x) ) $$


$$ \arg(q) = \operatorname{atan2}( Im[q],Re[q] ) $$

The problem is now reduced to a linear regression application. For best results, select values of x where $ \| G(x) \| $ (and thus $ \| H(x) \| $) are not near zero.

From the comments, it seems the OP found a solution, but I think this one would be a lot more efficient.

I am still puzzling about what $\phi$ means for a non-periodic function. For a pure complex tone, or even a mix of pure complex tones, it makes sense. Of course, for a pure complex tone a phase shift is indistinguishable from a time shift.


  • $\begingroup$ To address your confusion, in signal processing for complex signals phase refers to a rotation on the complex plane relative to a reference of 1 +j0. The signal need not be periodic to have a phase component; and this is often the confusion from equating delay with phase, which are two different parameters. $\endgroup$ Aug 11, 2021 at 19:10

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.