DSPRelated.com
Forums

Understanding inverse FFT results

Started by dkuhta February 7, 2005
Hi, first off I'm fairly new to DSP. That said, here is my situation.

1.I have an input array of time domain samples.
2.I feed this array into a FFT, then do an inverse FFT.
3.From the inverse results, I extract the "real" component.
4.I plug the iFFT real components into a new array.

Here is output from my program looking at one data sample:

time domain sample: -256.0
fft of sample: 622910.4945926662 + 869652.1640951419i
inverse fft : -255.99999999999918 + -1.8865049541588732E-13i
extracted real component: -256.0


question 1:
Isn't the point of an inverse FFT to get back to the time-domain
sample? I haven't applied any filters, so since I started with
-256.0, don't I want -256.0 after the iFFT?

question 2:
Do I have the basic understanding of this process correct? At this
point I simply want to feed my time-domain data through a FFT and back
to the time-domain to make sure all is working correctly. Once this
works, I will attempt to add filters.

Thank you.

"dkuhta" <deankuhta@yahoo.com> wrote in message
news:1107794474.626567.31530@l41g2000cwc.googlegroups.com...
> Hi, first off I'm fairly new to DSP. That said, here is my situation. > > 1.I have an input array of time domain samples. > 2.I feed this array into a FFT, then do an inverse FFT. > 3.From the inverse results, I extract the "real" component. > 4.I plug the iFFT real components into a new array. > > Here is output from my program looking at one data sample: > > time domain sample: -256.0 > fft of sample: 622910.4945926662 + 869652.1640951419i > inverse fft : -255.99999999999918 + -1.8865049541588732E-13i > extracted real component: -256.0 > > > question 1: > Isn't the point of an inverse FFT to get back to the time-domain > sample? I haven't applied any filters, so since I started with > -256.0, don't I want -256.0 after the iFFT?
Yes - that's correct. Ideally yes. Your actual result is so close to -256.0 that I'm surprised that you are bothered by the result you got.
> question 2: > Do I have the basic understanding of this process correct? At this > point I simply want to feed my time-domain data through a FFT and back > to the time-domain to make sure all is working correctly. Once this > works, I will attempt to add filters.
Yes, you do have the basic understanding of the process correct. You might want to read up on 'windowing' as it relates to FFT and iFFT before you get too far along. Cheers Bhaskar
thanks Bhaskar

Answer me this. The new audio (after FFT and iFFT) is just static. For
example, if I run a sound clip of speech through my program, the
FFT/iFFT generated file has the same speech pattern, but where the
speech should be there is just static. Does that make sense? I felt
like I was missing something in the FFT/iFFT process and my results
were flawed, that's why I posted originally. It's possible that my
problem lies in the coversion from doubles to bytes, but who knows...

HA!

yes, it was the conversion to bytes after the fact that was causing the
static problem! 

Thanks for you input Bhaskar.

Bhaskar Thiagarajan wrote:
> "dkuhta" <deankuhta@yahoo.com> wrote in message > news:1107794474.626567.31530@l41g2000cwc.googlegroups.com... > > Hi, first off I'm fairly new to DSP. That said, here is my
situation.
> > > > 1.I have an input array of time domain samples. > > 2.I feed this array into a FFT, then do an inverse FFT. > > 3.From the inverse results, I extract the "real" component. > > 4.I plug the iFFT real components into a new array. > > > > Here is output from my program looking at one data sample: > > > > time domain sample: -256.0 > > fft of sample: 622910.4945926662 + 869652.1640951419i > > inverse fft : -255.99999999999918 + -1.8865049541588732E-13i > > extracted real component: -256.0 > > > > > > question 1: > > Isn't the point of an inverse FFT to get back to the time-domain > > sample? I haven't applied any filters, so since I started with > > -256.0, don't I want -256.0 after the iFFT? > > Yes - that's correct. > Ideally yes. Your actual result is so close to -256.0 that I'm
surprised
> that you are bothered by the result you got.
Hi Bhaskar I agree with you, the OP appears to have done everything correctly. As for the close results, it takes a bit of training to evaluate the numbers. Seeing an imaginary component where one supplied a real number does confuse people the first few times they see that. One really needs to be made aware of the "e-13" on the far right end, and be inspired to contemplate that term, to actually understand the numbers. As one needs to be made aware that the real part is correct to 15 significant digits. As you say, it's not a big deal but it could be very confusing the first couple of times one sees it. I don't remeber if Rick commented on this particular point in his book. If he didn't do so already, I think it would be another one of those detail gems that could be included in a 3rd edition. Rune
This is a multi-part message in MIME format.

------=_NextPart_000_0020_01C50DC8.94DA1E30
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

> Bhaskar Thiagarajan wrote: >> "dkuhta" <deankuhta@yahoo.com> wrote in message >> news:1107794474.626567.31530@l41g2000cwc.googlegroups.com... >> > Hi, first off I'm fairly new to DSP. That said, here is my > situation. >> > >> > 1.I have an input array of time domain samples. >> > 2.I feed this array into a FFT, then do an inverse FFT. >> > 3.From the inverse results, I extract the "real" component. >> > 4.I plug the iFFT real components into a new array. >> > >> > Here is output from my program looking at one data sample: >> > >> > time domain sample: -256.0
???????
>> > fft of sample: 622910.4945926662 + 869652.1640951419i
??????? How do you work this out? If I provide a single sample to an FFT I just = get the same result at the output. =20
>> > inverse fft : -255.99999999999918 + -1.8865049541588732E-13i >> > extracted real component: -256.0 >> > >> > >> > question 1: >> > Isn't the point of an inverse FFT to get back to the time-domain >> > sample? I haven't applied any filters, so since I started with >> > -256.0, don't I want -256.0 after the iFFT? >> >> Yes - that's correct. >> Ideally yes. Your actual result is so close to -256.0 that I'm > surprised >> that you are bothered by the result you got.
I'm missing something somewhere - did you actually put a load of samples = into your FFT then just pick one of the outputs to show in your example = ? Puzzled Mike. ------=_NextPart_000_0020_01C50DC8.94DA1E30 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2900.2523" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY> <DIV><FONT face=3DArial size=3D2>&gt; Bhaskar Thiagarajan = wrote:<BR>&gt;&gt;=20 "dkuhta" &lt;</FONT><A href=3D"mailto:deankuhta@yahoo.com"><FONT = face=3DArial=20 size=3D2>deankuhta@yahoo.com</FONT></A><FONT face=3DArial size=3D2>&gt; = wrote in=20 message<BR>&gt;&gt; </FONT><A=20 href=3D"news:1107794474.626567.31530@l41g2000cwc.googlegroups.com"><FONT = face=3DArial=20 size=3D2>news:1107794474.626567.31530@l41g2000cwc.googlegroups.com</FONT>= </A><FONT=20 face=3DArial size=3D2>...<BR>&gt;&gt; &gt; Hi, first off I'm fairly new = to DSP. That=20 said, here is my<BR>&gt; situation.<BR>&gt;&gt; &gt;<BR>&gt;&gt; &gt; = 1.I have=20 an input array of time domain samples.<BR>&gt;&gt; &gt; 2.I feed this = array into=20 a FFT, then do an inverse FFT.<BR>&gt;&gt; &gt; 3.From the inverse = results, I=20 extract the "real" component.<BR>&gt;&gt; &gt; 4.I plug the iFFT real = components=20 into a new array.<BR>&gt;&gt; &gt;<BR>&gt;&gt; &gt; Here is output from = my=20 program looking at one data sample:<BR>&gt;&gt; &gt;<BR>&gt;&gt; &gt; = time=20 domain sample: -256.0</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV> <DIV><FONT face=3DArial color=3D#800080 size=3D2>???????<BR>&gt;&gt; = &gt; fft of=20 sample: 622910.4945926662 + 869652.1640951419i<BR>???????</FONT></DIV> <DIV><FONT face=3DArial size=3D2><FONT color=3D#800080>How do you work = this out? If=20 &nbsp;I provide a single sample to an FFT I just get the same result at = the=20 output.</FONT>&nbsp; </FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV> <DIV><FONT face=3DArial size=3D2>&gt;&gt; &gt; inverse fft : = -255.99999999999918 +=20 -1.8865049541588732E-13i<BR>&gt;&gt; &gt; extracted real component:=20 -256.0<BR>&gt;&gt; &gt;<BR>&gt;&gt; &gt;<BR>&gt;&gt; &gt; question=20 1:<BR>&gt;&gt; &gt; Isn't the point of an inverse FFT to get back to the = time-domain<BR>&gt;&gt; &gt; sample? I haven't applied any filters, so = since I=20 started with<BR>&gt;&gt; &gt; -256.0, don't I want -256.0 after the=20 iFFT?<BR>&gt;&gt;<BR>&gt;&gt; Yes - that's correct.<BR>&gt;&gt; Ideally = yes.=20 Your actual result is so close to -256.0 that I'm<BR>&gt; = surprised<BR>&gt;&gt;=20 that you are bothered by the result you got.<BR></FONT></DIV> <DIV><FONT face=3DArial size=3D2>I'm missing something somewhere - did = you actually=20 put a load of samples into your FFT then just pick one of the outputs to = show in=20 your example ?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV> <DIV><FONT face=3DArial size=3D2>Puzzled Mike.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>&nbsp;</DIV></FONT></BODY></HTML> ------=_NextPart_000_0020_01C50DC8.94DA1E30--
Rune Allnor wrote:

  ...

> One really needs to be made aware of the "e-13" on the far right > end, and be inspired to contemplate that term, to actually understand > the numbers. As one needs to be made aware that the real part is > correct to 15 significant digits. As you say, it's not a big deal > but it could be very confusing the first couple of times one sees it. > > I don't remeber if Rick commented on this particular point in his > book. If he didn't do so already, I think it would be another one > of those detail gems that could be included in a 3rd edition.
Isn't exponential notation taught in high school algebra any more? The only new thing to be learned for reading computer printouts is that 1E-13 is shorthand for 1*10^-13. Imagine that I pay for 256 liters of fuel, but get only 255.99999999999918. I would be embarrassed to complain that the delivery was .082 picoliters short. If the imaginary part is a contaminant, even .188 picoliters of it leaves the fuel quite pure. All people who use numbers should be required to gain competence with a slide rule. 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;
> I'm missing something somewhere - did you actually put a load of
samples into your FFT then just pick one of the outputs to show in your example ?
> > Puzzled Mike.
um, yea. Why is that puzzling? Maybe I'm missing something somewhere...
Jerry Avins wrote:
> Rune Allnor wrote: > > ... > > > One really needs to be made aware of the "e-13" on the far right > > end, and be inspired to contemplate that term, to actually
understand
> > the numbers. As one needs to be made aware that the real part is > > correct to 15 significant digits. As you say, it's not a big deal > > but it could be very confusing the first couple of times one sees
it.
> > > > I don't remeber if Rick commented on this particular point in his > > book. If he didn't do so already, I think it would be another one > > of those detail gems that could be included in a 3rd edition. > > Isn't exponential notation taught in high school algebra any more?
The
> only new thing to be learned for reading computer printouts is that > 1E-13 is shorthand for 1*10^-13.
I don't know about high school, but that ought to get taught at least in college. Sorry if I'm confusing you Americans, what I think of as "high school" is the last years of compulsary school where the students leave at 16. I think of college as an alternative to university, where students enter at age 19 - 20. In between we wave something that translates to "extension school", where the student can choose to either prepare for university-college or get vocatinal traing to become a carpenter, electrician,...
> Imagine that I pay for 256 liters of fuel, but get only > 255.99999999999918. I would be embarrassed to complain that the
delivery
> was .082 picoliters short. If the imaginary part is a contaminant,
even
> .188 picoliters of it leaves the fuel quite pure.
Sure. As for myself, I didn't acquire that pragmatic attitude to numbers until I started to work with numerical stuff. I implemented some routines and had to contemplate the results. The very first routine I implemented was the FFT where I, too, had to stop and think through the very same questions that spawned this thread. With other routines I had some reference runs with known input and output. It takes a very short time to become aware of numerical accuracy when working like that. But it does require a concious effort to contemplate the numbers.
> All people who use numbers should be required to gain competence with
a
> slide rule.
Ouch! That leaves me out. I know I've seen my father's slide rule in a box where he keeps his old stuff, but I never saw it used. Rune
"dkuhta" <deankuhta@yahoo.com> wrote in message 
news:1107918417.946400.260870@g14g2000cwa.googlegroups.com...
> >> I'm missing something somewhere - did you actually put a load of > samples into your FFT then just pick one of the outputs to show in your > example ? >> >> Puzzled Mike. > > um, yea. Why is that puzzling? Maybe I'm missing something somewhere... >
O.K. dkuhta - it's clear now, thanks. Mentioning one of the frequency components at the output of your N point FFT didn't really have any bearing on your problem but I mistakenly thought it might. Best of Luck - Mike