# Scaling factor in inverse fourier transform

Started by April 10, 2007
```Hi all,

I tried to calculate the autocorrelation from FFT using C. As far as I
know the input for the inverse FT is the power spectrum density of the
data X(t)
PSD = (Xreal(f)^2 + Ximag(f)^2) / N, N is the length of the real
number
After calculating the inverse FT, I scaled the result with 1/N but the
result is not 1 (less than 1).

I wonder if I made mistake with the scaling factor or something else.

Titi

```
```On Apr 10, 5:06 am, "Titi Anggono" <titi.angg...@gmail.com> wrote:
> Hi all,
>
> I tried to calculate the autocorrelation from FFT using C. As far as I
> know the input for the inverse FT is the power spectrum density of the
> data X(t)
> PSD = (Xreal(f)^2 + Ximag(f)^2) / N, N is the length of the real
> number
> After calculating the inverse FT, I scaled the result with 1/N but the
> result is not 1 (less than 1).
>
> I wonder if I made mistake with the scaling factor or something else.
> Looking forward with your help.
>
> Titi

There's nothing wrong with having an autocorrelation sequence with
values greater than one. It is defined by:

r[k] = E(x[n]*conj(x[n-k]))

for a wide-sense stationary signal x[n]. This can obviously be greater
than one, no issue there. As far as scaling factors go, as long as
between your FFT and IFFT you have a total factor of 1/N, you're fine.
You could have no scaling factor on the FFT and a 1/N on the IFFT, or
you could put 1/sqrt(N) on both. They will give you different
intermediate results, but you'll get the same values if you do an FFT-
IFFT operation on a dataset.

Jason

```
```On 2007-04-10 07:15:28 -0300, cincydsp@gmail.com said:

> On Apr 10, 5:06 am, "Titi Anggono" <titi.angg...@gmail.com> wrote:
>> Hi all,
>>
>> I tried to calculate the autocorrelation from FFT using C. As far as I
>> know the input for the inverse FT is the power spectrum density of the
>> data X(t)
>> PSD = (Xreal(f)^2 + Ximag(f)^2) / N, N is the length of the real
>> number
>> After calculating the inverse FT, I scaled the result with 1/N but the
>> result is not 1 (less than 1).
>>
>> I wonder if I made mistake with the scaling factor or something else.
>> Looking forward with your help.
>>
>> Titi
>
> There's nothing wrong with having an autocorrelation sequence with
^^^^^^^^^^^^^^^
autocovariance

> values greater than one. It is defined by:
>
>      r[k] = E(x[n]*conj(x[n-k]))
>
> for a wide-sense stationary signal x[n]. This can obviously be greater
> than one, no issue there. As far as scaling factors go, as long as
> between your FFT and IFFT you have a total factor of 1/N, you're fine.
> You could have no scaling factor on the FFT and a 1/N on the IFFT, or
> you could put 1/sqrt(N) on both. They will give you different
> intermediate results, but you'll get the same values if you do an FFT-
> IFFT operation on a dataset.
>
> Jason

The autocorrelation is the autocovariance divided by the its value
at a lag of 0. The autocovariance definitions will usually expect the
mean to be 0.

(This is a rather common mislabelling of related concepts.)

```
```Gordon Sande wrote:

> The autocorrelation is the autocovariance divided by the its value
> at a lag of 0. The autocovariance definitions will usually expect the
> mean to be 0.
>
> (This is a rather common mislabelling of related concepts.)

There is some disagreement on my bookshelf on this topic. Usually,
texts concerned with the statistics of time series define the
autocovariance function as

c_xx(k1,k2) := E[ ( X(k1) - E[ X(k1) ] ) ( X(k2) - E[ X(k2) ] )
= E[X(k1) X(k2)] - E[X(k1)] E[X(k2)]

and the autocorrelation as

r_xx(k1,k2) := c_xx(k1,k2) / sqrt( Var(X(k1)) Var(X(k2)) ).

OTH, signal processing texts (eg. [1-4]) define the autocovariance in
the same way, but autocorrelation simply as

r_xx(k1,k2) := E[X(k1) X(k2)].

Rather confusing.

Regards,
Andor

 Oppenheim, Schafer: "Digital Signal Processing"
 Proakis, Manolakis: "Digital Signal Processing"
 Hayes: "Statistical Digital Signal Processing And Modeling"
 Bendat, Piersol: "Measurement And Analysis Of Random Data"

```