0
$\begingroup$

In this article the real valued time domain signal is transformed to the frequency domain to extract some features like mean or variance.

But after transform to the frequency domain I calculate average hourly values (original measurements are 1/hour), so I need the signal in the frequency domain with the same length as the signal in the time domain.

Later I need features as real numbers (e.g. mean, variance), so I also need real numbers in the frequency domain. To this end, I think they use PSD. But after using Scipy's PSD (Welch estimation) I get much shorter array.

Question:

  1. How can I get real valued array in the frequency domain from the signal with the same length as the original signal?

  2. How should I use FFT / real FFT / PSD to get this (what arguments' values should I use)?

  3. Would taking absolute values of the FFT output make sense?

$\endgroup$
3
  • 1
    $\begingroup$ after the DFT (the FFT is but an implementation of the DFT), the values are in general complex. If you don't want that, you don't want the DFT/FFT, but it's not clear what you actually want. Engineering thought: First define what you need before describing a solution. Also, the DFT is a mapping between vectors of the same length, so the "same length" is inherently never a problem. $\endgroup$ May 16 at 11:41
  • $\begingroup$ @MarcusMüller I want to recreate the paper results. I know it's not precise and I just guess what authors meant. I just need to do something with those complex numbers which would at least make sense. $\endgroup$
    – qalis
    May 16 at 11:43
  • $\begingroup$ Well, then the question is not what you want to express with these numbers, but what the paper wants to express with these numbers. Maybe it's as easy as taking the magnitude (squared?), maybe not. But to be brutally honest, from a signal processing scientist's point of view, a paper that isn't mathematically accurate is inaccurate and irreproducible to a first approximation. However, it seems eq. (3) in that paper is actually an actual formula, so maybe we're confusing ourselves here? $\endgroup$ May 16 at 11:59
1
$\begingroup$

Since you are reproducing the paper's results, read it carefully.

At the bottom of page 4 it says

This representation is formed by complex numbers, eliminating the imaginary part of each number in the frequency-domain signal. For this transformation, it is needed to calculate the power spectral density (PSD), as shown in Equation (3), $$ P = \lim_{T\to\infty} \frac{1}{T} \int_0^T |x(k)|^2 dt \tag{3} $$ where $P$ represents the energy from the signal, $T$ represents the length of the signal lapse and $x(k)$ represents the frequency-domain signal. The spectrum is normalized by the length of the signal.

The PSD is a real function with respect to frequency $k$, so it has the same length of FFT result $x(k)$ if you keepace with Eq. (3).

There are many methods to estimate PSD, but if you want to recreate the results in the paper, you should use exactly the same equation.

$\endgroup$
1
  • $\begingroup$ It turned out that I can't really use the library PSD functions and had to use low level functions and code this by hand, as you suggested. Thanks! $\endgroup$
    – qalis
    May 17 at 6:41

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.