DSPRelated.com
Forums

is this what people usually do? (about Discrete Fourier transform)

Started by Unknown December 10, 2006
hi

I was experimenting with Discrete Fourier Transform.
1. I notice that you have to keep the complex values after
tranformation, in order to get back an "inverse transform". Is this
always the case? I tried to "keep only the Real part" or "only the
absolute values", but couldn't get back f(t).
2. People use absolute values for visualization or analysis right? Is
there reason for keeping the complex values for analysis?

Here is my experiment using Maple:
N:=10:f:=[1,1,1,1,1,0,0,0,0,0]:
F:=simplify([seq(sum(f[k+1]*exp(2*Pi*I/N)^(-k*j),k=0..N-1),j=0..N-1)]);evalf(map(abs,F));
simplify([seq(sum(F[j+1]*exp(2*Pi*I/N)^(k*j),j=0..N-1)/N,k=0..N-1)]); #
inverse
simplify(sum(map(abs^2,f)[j],j=1..N));simplify(sum(map(abs^2,F)[j],j=1..N))/N;
#[Parseval's]
# don't work
F:=simplify([seq(Re(sum(f[k+1]*exp(2*Pi*I/N)^(-k*j),k=0..N-1)),j=0..N-1)]);evalf(map(abs,F));
simplify([seq(Re(sum(F[j+1]*exp(2*Pi*I/N)^(k*j),j=0..N-1))/N,k=0..N-1)]);
# inverse
# don't work
F:=simplify([seq(abs(sum(f[k+1]*exp(2*Pi*I/N)^(-k*j),k=0..N-1)),j=0..N-1)]);evalf(map(abs,F));
simplify([seq(abs(sum(F[j+1]*exp(2*Pi*I/N)^(k*j),j=0..N-1))/N,k=0..N-1)]);
# inverse

paulwv...@yahoo.ca skrev:
> hi > > I was experimenting with Discrete Fourier Transform. > 1. I notice that you have to keep the complex values after > tranformation, in order to get back an "inverse transform". Is this > always the case?
Yes.
> I tried to "keep only the Real part" or "only the > absolute values", but couldn't get back f(t).
By doing that, you throw away half the information contained in the signal.
> 2. People use absolute values for visualization or analysis right?
Yep. The bulk of the information that is interesting for a person to see, is contained in the magnitude.
> Is > there reason for keeping the complex values for analysis?
They are necessary to get your signal processing to work. Rune
Rune Allnor wrote:
> paulwv...@yahoo.ca skrev: > > hi > > > > I was experimenting with Discrete Fourier Transform. > > 1. I notice that you have to keep the complex values after > > tranformation, in order to get back an "inverse transform". Is this > > always the case? > > Yes. > > > I tried to "keep only the Real part" or "only the > > absolute values", but couldn't get back f(t). > > By doing that, you throw away half the information contained > in the signal. > > > 2. People use absolute values for visualization or analysis right? > > Yep. The bulk of the information that is interesting for > a person to see, is contained in the magnitude. > > > Is > > there reason for keeping the complex values for analysis? > > They are necessary to get your signal processing to work.
I was asking a question about the physical meaning of wav file samples, earlier in ' rec.audio.pro'. Can those wav file samples be considered as magnitude or "absolute values of complex numbers"? That means voltages that we measure are also "absolute values of complex numbers"?
paulwvanc@yahoo.ca wrote:
> hi > > I was experimenting with Discrete Fourier Transform. > 1. I notice that you have to keep the complex values after > tranformation, in order to get back an "inverse transform". Is this > always the case? I tried to "keep only the Real part" or "only the > absolute values", but couldn't get back f(t).
When you convert a time series into the frequency domain using a DFT you are really just rewriting the time series as a sum of shifted sin waves of various magnitudes and frequencies (also in the time domain). When you add up all those shifted sin waves you get the original signal back (the inverse transform). Now, those magnitudes and shifts assigned to each sine wave are represented by complex numbers when you perform a DFT, because there are two parts to it, so you can't throw any of it away. Now if you could convert any time series into a sum of sine waves with no shifts, then you wouldn't need any imaginary numbers to begin with, there would only be one number associated with each sine wave, the magnitude, but you can't do that in the general case, you got to shift those little bastard sine waves most all the time.
paulwvanc@yahoo.ca writes:

> hi > > I was experimenting with Discrete Fourier Transform. > 1. I notice that you have to keep the complex values after > tranformation, in order to get back an "inverse transform". Is this > always the case?
It is *usually* the case, but it is not *always* the case. A counter example is when you take the DFT of a real, symmetric time-domain signal, in which case the DFT is purely real.
> I tried to "keep only the Real part" or "only the > absolute values", but couldn't get back f(t).
Right, that's normal. You must (normally) use both parts.
> 2. People use absolute values for visualization or analysis right?
For visual analysis, that's usually the case. This is referred to as the "amplitude response." Sometimes you are also interested in the "phase response."
> Is there reason for keeping the complex values for analysis?
If only the amplitude response is needed, then you don't need to keep the complex signal - just the magnitude. -- % Randy Yates % "Ticket to the moon, flight leaves here today %% Fuquay-Varina, NC % from Satellite 2" %%% 919-577-9882 % 'Ticket To The Moon' %%%% <yates@ieee.org> % *Time*, Electric Light Orchestra http://home.earthlink.net/~yatescr
Randy Yates wrote:
> paulwvanc@yahoo.ca writes: > > > hi > > > > I was experimenting with Discrete Fourier Transform. > > 1. I notice that you have to keep the complex values after > > tranformation, in order to get back an "inverse transform". Is this > > always the case? > > It is *usually* the case, but it is not *always* the case. A counter > example is when you take the DFT of a real, symmetric time-domain > signal, in which case the DFT is purely real.
I tried one example but it didn't work... N:=10:f:=[1,1,1,0,0,0,0,1,1,1]: # this is time symmetric right? F:=simplify([seq(sum(f[k+1]*exp(2*Pi*I/N)^(-k*j),k=0..N-1),j=0..N-1)]); simplify([seq(sum(F[j+1]*exp(2*Pi*I/N)^(k*j),j=0..N-1)/N,k=0..N-1)]); F still contains complex values, and it's not simplification problem... What did I do wrong? (From what you are saying, I thought I could simply "flip" the signal and add that to the orginal signal, therefore double the period. That way I can keep all arithmetics in real?)
> > > I tried to "keep only the Real part" or "only the > > absolute values", but couldn't get back f(t). > > Right, that's normal. You must (normally) use both parts. > > > 2. People use absolute values for visualization or analysis right? > > For visual analysis, that's usually the case. This is referred to > as the "amplitude response." Sometimes you are also interested > in the "phase response." > > > Is there reason for keeping the complex values for analysis? > > If only the amplitude response is needed, then you don't need > to keep the complex signal - just the magnitude. > -- > % Randy Yates % "Ticket to the moon, flight leaves here today > %% Fuquay-Varina, NC % from Satellite 2" > %%% 919-577-9882 % 'Ticket To The Moon' > %%%% <yates@ieee.org> % *Time*, Electric Light Orchestra > http://home.earthlink.net/~yatescr
paulwvanc@yahoo.ca wrote:
> Rune Allnor wrote: >> paulwv...@yahoo.ca skrev: >>> hi >>> >>> I was experimenting with Discrete Fourier Transform. >>> 1. I notice that you have to keep the complex values after >>> tranformation, in order to get back an "inverse transform". Is this >>> always the case? >> Yes. >> >>> I tried to "keep only the Real part" or "only the >>> absolute values", but couldn't get back f(t). >> By doing that, you throw away half the information contained >> in the signal. >> >>> 2. People use absolute values for visualization or analysis right? >> Yep. The bulk of the information that is interesting for >> a person to see, is contained in the magnitude. >> >>> Is >>> there reason for keeping the complex values for analysis? >> They are necessary to get your signal processing to work. > > I was asking a question about the physical meaning of wav file samples, > earlier in ' rec.audio.pro'. > Can those wav file samples be considered as magnitude or "absolute > values of complex numbers"? > That means voltages that we measure are also "absolute values of > complex numbers"?
No. Those numbers represent (or could represent) physical measurements. They are real numbers, not complex. When those numbers are processed in some ways, a Fourier transform being one of those ways, the results are two quantities per sample. They can be expressed as real and imaginary parts, magnitude and phase, or cosine and sine parts. The inverse transform will recreate the original, also purely real except for small imaginary parts due to truncation errors. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
paulwvanc@yahoo.ca writes:

> Randy Yates wrote: >> paulwvanc@yahoo.ca writes: >> >> > hi >> > >> > I was experimenting with Discrete Fourier Transform. >> > 1. I notice that you have to keep the complex values after >> > tranformation, in order to get back an "inverse transform". Is this >> > always the case? >> >> It is *usually* the case, but it is not *always* the case. A counter >> example is when you take the DFT of a real, symmetric time-domain >> signal, in which case the DFT is purely real. > > I tried one example but it didn't work... > N:=10:f:=[1,1,1,0,0,0,0,1,1,1]: # this is time symmetric right? > F:=simplify([seq(sum(f[k+1]*exp(2*Pi*I/N)^(-k*j),k=0..N-1),j=0..N-1)]); > simplify([seq(sum(F[j+1]*exp(2*Pi*I/N)^(k*j),j=0..N-1)/N,k=0..N-1)]); > > F still contains complex values, and it's not simplification problem... > What did I do wrong?
Nothing. It's my fault for not being more specific. The symmetry is a little strange - it should be that the N-1 samples from n = 1 to n = N-1 (starting the count from 0) should be symmetric. If this is an odd number of samples (i.e., if N is even), then the "center" sample doesn't matter. Or, stated another way, it should be that if you appended x[0] to the end of your N-sample array, so that you had the N+1 samples x[0], x[1], ..., x[N-1], x[0], then these N+1 samples must be symmetric.
> (From what you are saying, I thought I could simply "flip" the signal > and add that to the orginal signal, therefore double the period. That > way I can keep all arithmetics in real?)
That's almost right. Flip the last N-1 samples and append that to the array and you'd get what you want. -- % Randy Yates % "She tells me that she likes me very much, %% Fuquay-Varina, NC % but when I try to touch, she makes it %%% 919-577-9882 % all too clear." %%%% <yates@ieee.org> % 'Yours Truly, 2095', *Time*, ELO http://home.earthlink.net/~yatescr
joep1000@yahoo.com wrote:

(snip)

> Now if you could convert any time series into a sum of sine waves with > no shifts, then you wouldn't need any imaginary numbers to begin with, > there would only be one number associated with each sine wave, the > magnitude, but you can't do that in the general case, you got to shift > those little bastard sine waves most all the time.
You mean like the Discrete Sine Transform? -- glen
Randy Yates wrote:
> paulwvanc@yahoo.ca writes: > > > Randy Yates wrote: > >> paulwvanc@yahoo.ca writes: > >> > >> > hi > >> > > >> > I was experimenting with Discrete Fourier Transform. > >> > 1. I notice that you have to keep the complex values after > >> > tranformation, in order to get back an "inverse transform". Is this > >> > always the case? > >> > >> It is *usually* the case, but it is not *always* the case. A counter > >> example is when you take the DFT of a real, symmetric time-domain > >> signal, in which case the DFT is purely real. > > > > I tried one example but it didn't work... > > N:=10:f:=[1,1,1,0,0,0,0,1,1,1]: # this is time symmetric right? > > F:=simplify([seq(sum(f[k+1]*exp(2*Pi*I/N)^(-k*j),k=0..N-1),j=0..N-1)]); > > simplify([seq(sum(F[j+1]*exp(2*Pi*I/N)^(k*j),j=0..N-1)/N,k=0..N-1)]); > > > > F still contains complex values, and it's not simplification problem... > > What did I do wrong? > > Nothing. It's my fault for not being more specific. > > The symmetry is a little strange - it should be that the N-1 samples > from n = 1 to n = N-1 (starting the count from 0) should be > symmetric. If this is an odd number of samples (i.e., if N is even), > then the "center" sample doesn't matter. > > Or, stated another way, it should be that if you appended x[0] to > the end of your N-sample array, so that you had the N+1 samples > > x[0], x[1], ..., x[N-1], x[0], > > then these N+1 samples must be symmetric. > > > (From what you are saying, I thought I could simply "flip" the signal > > and add that to the orginal signal, therefore double the period. That > > way I can keep all arithmetics in real?) > > That's almost right. Flip the last N-1 samples and append that to > the array and you'd get what you want.
Now when I ponder more about it, there is one problem though. How would I "adjust for" the added signal in the frequency domain? In oder to avoid complex arithmetics, I have introduced a new problem to deal with. Is there a clean way to deal with it?
> -- > % Randy Yates % "She tells me that she likes me very much, > %% Fuquay-Varina, NC % but when I try to touch, she makes it > %%% 919-577-9882 % all too clear." > %%%% <yates@ieee.org> % 'Yours Truly, 2095', *Time*, ELO > http://home.earthlink.net/~yatescr