Reply by Vanamali July 20, 20032003-07-20
stenasc@yahoo.com (Bob) wrote in message news:<20540d3a.0307180405.7796b21a@posting.google.com>...
> Hi all, > > Just wondering about the dc component of an fft.
I think a more correct term to use than "dc component" will be "sample mean". When a signal has a DC component, there will be an impulse at zero frequency; however, when the signal has non-zero sample mean, the transform value at zero frequency value will be non-zero. This does not mean the signal has a DC component. Your question of why you see a non-zero value has been explained very nicely by others. And don't call it "... of an fft". FFT is just a fast algorithm for computing the DFT; at the end of it you get DFT coefficients, _not_ FFT coefficients. But terms like FFT coefficients, FFT spectrum, etc. are so well entrenched in the literature that it is a battle that has been lost long time ago. Sigh.
Reply by Fred Marshall July 18, 20032003-07-18
"Jim Thomas" <jthomas@bittware.com> wrote in message
news:3F1801ED.5F06CBA4@bittware.com...
> Bob wrote: > > > > Hi all, > > > > Just wondering about the dc component of an fft. > > > > If I have an input signal e.g a single cosine wave. When I sample it > > for say a 128 point fft, should it have a dc component value. > > In my fft, I sum the input samples and calculate the average. > > > > I half expected it to be zero (no dc component), but this wasn't the
case.
> > > > Can anyone shed some light upon this ? > > > > If the dc component of said cosine wave isn't zero, what effect will it > > have on the fft result ? > > > > As always...thanks to everyone who replies > > > > Bob > > If you have an integer number of periods in your cosine, then the DC > component will be zero. If you have say 4.8 periods of a cosine in your > data block, you will get some DC. This is because the cosine frequency > does not fall on a "bin center" (as it is often called). The DC > component is really just the average of all the samples. The positive > part of the cosine will be exactly cancelled by the negative part, but > if the cosine ends before a period completes, the cancellation is > incomplete. > > When the input frequency does not fall on a bin center, you'll get > leakage into frequency bins other than DC too.
Talking about bins is one way to do it. So, I'm not disagreeing. It is simpler to think in terms of the dc term of the transform being the average. As others have said, if the number of periods in the epoch taken isn't an integer then there won't be zero average. This gets a little more complicated if you're doing a Discrete Fourier Transform. A discrete Fourier Transform or the Fast version: FFT will be made up of a number of samples. The span of those samples will be one sample interval short of a full period. Like this: The temporal epoch you have in mind is T. The number of samples you have in mind is N. The sample interval is T/N. The temporal epoch is spanned by N+1 samples. The temporal epoch contains N sample intervals. (The sampling frequency is N/T and the frequency sampling interval is 1/T) There are N samples in frequency spanning (N-1)/T (There are N+1 samples in frequency spanning N/T Hz). N time samples span N-1 sample intervals (then it is assumed to repeat with x(0)=x(N)). The period spans T seconds and N sample intervals. So, if: - the sample interval is 1 second, - the sample epoch is 128 seconds - there will be 128 samples spanning 127 seconds and repeating at 128 seconds intervals. - if the first sample is at time zero, the last sample is at time 127 seconds. So, if: - you define a signal to be cos(2*pi*0.1*t), - you sample it at intervals of 1 second, - you take 100 samples - the last sample is at 99 seconds, not 100 seconds. The average is zero unless you repeat the first sample as the last. That's easy to see if you sample a single period of a cosine at intervals of pi/2. The samples would be 1, 0, -1, 0, 1 which has an average of 0.2 The average of 1, 0 , -1, 0 has an average of zero - the first and last samples aren't the same but it represents one period nonetheless. Here I've viewed spans of time and frequency as starting and ending on a sample. If you view each sample as "representing" the sample instant and all of the time thereafter up to but not inucluding the next sample, then the number of samples and the number of intervals coincides. Maybe that's a better way..... Fred
Reply by Jerry Avins July 18, 20032003-07-18
Bob wrote:
> > Hi all, > > Just wondering about the dc component of an fft. > > If I have an input signal e.g a single cosine wave. When I sample it > for say a 128 point fft, should it have a dc component value. > In my fft, I sum the input samples and calculate the average. > > I half expected it to be zero (no dc component), but this wasn't the case. > > Can anyone shed some light upon this ? > > If the dc component of said cosine wave isn't zero, what effect will it > have on the fft result ? > > As always...thanks to everyone who replies > > Bob
By definition, the DC component of a FULL CYCLE of a sinusoid is zero. This is a cosine sampled six times per cycle at an arbitrary phase: ... 1, 1, 0, -1, -1, 0, .... For a full cycle, the average is clearly zero. The DC value of half a cycle depends on how the half is chosen. Of the six possible ways, two are zero, two are 2/3, and two are -2/3. I can add more, but I trust you can take it from here. 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;
Reply by Jim Thomas July 18, 20032003-07-18
Bob wrote:
> > Hi all, > > Just wondering about the dc component of an fft. > > If I have an input signal e.g a single cosine wave. When I sample it > for say a 128 point fft, should it have a dc component value. > In my fft, I sum the input samples and calculate the average. > > I half expected it to be zero (no dc component), but this wasn't the case. > > Can anyone shed some light upon this ? > > If the dc component of said cosine wave isn't zero, what effect will it > have on the fft result ? > > As always...thanks to everyone who replies > > Bob
If you have an integer number of periods in your cosine, then the DC component will be zero. If you have say 4.8 periods of a cosine in your data block, you will get some DC. This is because the cosine frequency does not fall on a "bin center" (as it is often called). The DC component is really just the average of all the samples. The positive part of the cosine will be exactly cancelled by the negative part, but if the cosine ends before a period completes, the cancellation is incomplete. When the input frequency does not fall on a bin center, you'll get leakage into frequency bins other than DC too. -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (703) 779-7770 In theory, theory and practice are the same, but in practice, they're not
Reply by One Usenet Poster July 18, 20032003-07-18
Bob wrote:

> Hi all, > > Just wondering about the dc component of an fft. > > If I have an input signal e.g a single cosine wave. When I sample it > for say a 128 point fft, should it have a dc component value. > In my fft, I sum the input samples and calculate the average. > > I half expected it to be zero (no dc component), but this wasn't the case. > > Can anyone shed some light upon this ? > > If the dc component of said cosine wave isn't zero, what effect will it > have on the fft result ? > > As always...thanks to everyone who replies > > Bob
Bob: Mathematically speaking, there should be no DC component for cos(x) or sin(x) (assuming exactly one period or lots of periods are used). This is true for any zero-mean signal. However, for a discrete FFT, depending on the sampling rate, you often get "spectral leakage" where strong spectral components bleed over into adjacent frequency bins. This could give you a small, non-zero DC component. Good luck, OUP
Reply by Rick Lyons July 18, 20032003-07-18
On 18 Jul 2003 05:05:05 -0700, stenasc@yahoo.com (Bob) wrote:

>Hi all, > >Just wondering about the dc component of an fft. > >If I have an input signal e.g a single cosine wave. When I sample it >for say a 128 point fft, should it have a dc component value. >In my fft, I sum the input samples and calculate the average. > >I half expected it to be zero (no dc component), but this wasn't the case. > >Can anyone shed some light upon this ? > >If the dc component of said cosine wave isn't zero, what effect will it >have on the fft result ? > >As always...thanks to everyone who replies > >Bob
Hi, if the 128-sample cosine wave is not an exact integer number of cycles, then the average of those 128 samples will not be zero, and the DC component of the 128-point FFT will not be zero. Good Luck, [-Rick-]
Reply by Bob July 18, 20032003-07-18
Hi all,

Just wondering about the dc component of an fft.

If I have an input signal e.g a single cosine wave. When I sample it
for say a 128 point fft, should it have a dc component value. 
In my fft, I sum the input samples and calculate the average.

I half expected it to be zero (no dc component), but this wasn't the case.

Can anyone shed some light upon this ?

If the dc component of said cosine wave isn't zero, what effect will it
have on the fft result ?

As always...thanks to everyone who replies

Bob