Time Series from spectrum

JPV

I am having a samll problem while converting a spectrum to a time series. I have read many article sand I htink I am applying the right procedure but I do not get the right results. Could you help to find the error?

I have a time series like: enter image description here

When I compute the spectrum I do: %number of points nPoints=length(timeSeries);

%time interval
dt=time(2)-time(1);

%Fast Fourier transform
p=abs(fft(timeSeries))./(nPoints/2);

%power of positive frequencies
spectrum=p(1:(nPoints/2)).^2;

%frequency
dfFFT=1/tDur;
frequency=(1:nPoints)*dfFFT;
frequency=frequency(1:(nPoints)/2);

%plot spectrum
semilogy(frequency,spectrum); grid on;
xlabel('Frequency [Hz]');
ylabel('Power Spectrum [N*m]^2/[Hz]');
title('SPD load signal');

And I obtain:

enter image description here

I think the spectrum is well computed. However now I need to go back and obtain a time series from this spectrum and I do:

df=frequency(2)-frequency(1);
ap = sqrt(2.*spectrum*df)';
%random number form -pi to pi    
epsilon=-pi + 2*pi*rand(1,length(ap));
%transform to time series
randomSeries=length(time).*real(ifft(pad(ap.*exp(epsilon.*i.*2.*pi),length(time))));
%Add the mean value
randomSeries=randomSeries+mean(timeSeries);

However, the plot looks like:

enter image description here

Where it is one order of magnitude lower than the original serie. Any recommendation?

twalberg

There are (at least) two things going on here. The first is that you are throwing away information, and then substituting random numbers for that information.

The FFT of a real sequence is a sequence of complex numbers consisting of a real and imaginary part. Converting those numbers to polar form gives you magnitude and phase angle. You are capturing the magnitude part with p=aps(fft(...)), but you are not capturing the phase angle (which would involve atan2(...)). You are then making up random numbers (epsilon=...) and using those to replace the original numbers when you reconstruct your time-series. Also, as the FFT of a real sequence has a particular symmetry, substituting random numbers for the phase angle destroys that symmetry, which means that the IFFT will in general no longer be a real sequence, but a sequence of complex numbers - and again, you're only looking at the real portion of the IFFT, so you're throwing away information again. If this is an audio signal, the results may sound somewhat like the original (or they may be completely different), but the waveform definitely won't match...

The second issue is that in many implementations, ifft(fft(...)) will scale the result by the number of points in the signal. There are several different ways to avoid that, with differing results, but sometimes more attractive in different scenarios, depending on what you are trying to do. You can either scale the fft() result before you do the ifft(), or scale the ifft() result at the end, or in some cases, I've even seen both being scaled by a factor of sqrt(N) - doing it twice has the end result of scaling the final result by N, but it is a bit less efficient since you do the scaling twice...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Matlab: trying to estimate multifractal spectrum from time series by histogram box-counting

From Dev

Remove hours from time series

From Dev

seaborn time series from pandas dataframe

From Dev

Linear Regression from Time Series Pandas

From Dev

Faster reading of time series from netCDF?

From Dev

Pandas time series index from list of dictionaries

From Dev

Drop the date from a matplotlib time series plot

From Dev

Time series from dataframe loses values

From Dev

Create a Time Series from a CSV file

From Dev

R: How to extract dates from a time series

From Dev

Fetch time series from Google BigQuery

From Dev

Getting a range of data from infinite time series

From Dev

How to get threshold from cumulative time series

From Dev

Pandas create time series from day counts

From Dev

Extracting parts of varying length from time series

From Dev

Convert data from CSV file time series

From Dev

How to find a linear trend from a time series?

From Dev

Time series arrangement and operations from telemetry experiment

From Dev

Create a Time Series from a CSV file

From Dev

reconstruct time series from given matrix

From Dev

Selecting regular intervals from time series

From Dev

Getting a range of data from infinite time series

From Dev

Extracting a (sampled) time series from an SQL DB

From Dev

R Rolling average from irregular time series

From Dev

Rolling window from time-series

From Dev

Audio frequency spectrum of a video at a given time

From Dev

Reduce time precision in a time series to minutes from seconds

From Dev

Create Pandas Time Serie from multiple Time Series with Python

From Dev

Reduce time precision in a time series to minutes from seconds

Related Related

HotTag

Archive