comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Complications with variance using FFTs
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Complications with variance using FFTs [message #40106] Thu, 22 July 2004 10:06
olde_english33 is currently offline  olde_english33
Messages: 7
Registered: June 2004
Junior Member
Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> wrote in message news:<onbri943hd.fsf@cow.physics.wisc.edu>...
> olde_english33@hotmail.com (Eric) writes:
>>
>> From what I can gather from my program, the positive frequencies are
>> those from 1:15. Then the frequencies from 16:30 are the complex
>> conjugates of the frequencies from 15:1. Therefore, I thinkt that IDL
>> is already accounting for the complex conjugate in the negative
>> frequencies, unless I am missing something.
>
> I think you are missing that when you multiply the positive frequency
> components by a complex phase, then you must also multiply the
> negative frequency components by the complex conjugate, i.e. the
> negative of that phase. To preserve a real signal that is.
>
> That's another probing question, is the final result of your technique
> real or complex?
>
> Craig

Using my technique of making the phase symmetric produces results that
are real, or very nearly real considering machine eps. I also tried
it using the technique you suggested above, but was again
unsuccessful. For example, one of the returned numbers was (30.3417,
-3.79635e-15). So I do not think that is the problem, but still have
no idea what the problem is. Do you have any more suggestions on
things to check? My colleague believes that inserting a random phase
is throwing off the ability to INVERSE FFT the data. Do you know if
this could be a possibility?

Eric
Re: Complications with variance using FFTs [message #40125 is a reply to message #40106] Wed, 21 July 2004 11:30 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
olde_english33@hotmail.com (Eric) writes:
>
> From what I can gather from my program, the positive frequencies are
> those from 1:15. Then the frequencies from 16:30 are the complex
> conjugates of the frequencies from 15:1. Therefore, I thinkt that IDL
> is already accounting for the complex conjugate in the negative
> frequencies, unless I am missing something.

I think you are missing that when you multiply the positive frequency
components by a complex phase, then you must also multiply the
negative frequency components by the complex conjugate, i.e. the
negative of that phase. To preserve a real signal that is.

That's another probing question, is the final result of your technique
real or complex?

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Complications with variance using FFTs [message #40126 is a reply to message #40125] Wed, 21 July 2004 10:53 Go to previous message
olde_english33 is currently offline  olde_english33
Messages: 7
Registered: June 2004
Junior Member
Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> wrote in message news:<onllheeqc8.fsf@cow.physics.wisc.edu>...
> olde_english33@hotmail.com (Eric) writes:
>>
>> Hello. First, I don't understand what you mean by "multiplied by
>> exp(-phi)? Secondly, consider the following code instead:
>
> I mean, that for a real signal, the Fourier components at negative
> frequencies are the complex conjugate of those at positive
> frequencies. Thus, EXP(IMAG*PHI) at positive frequencies becomes
> EXP(-IMAG*PHI) at negative frequencies, for arbitrary PHI. Since you
> are not changing to the complex conjugate at negative frequencies, I
> think that's where your problem lies.
>
>> Now I think all the code snipets are related correctly. I checked the
>> the average variance of all the xf1[*,i] was equal to
>> sum(avgspec1)/31.0 and that the average variance of xf2[*,i] was equal
>> to sum(avgspec2)/31.0. This check held. It works if I don't throw in
>> the symmetric random phase exp(e). Does this phase throw off the
>> variance? Is there any way to account for inputting this random
>> phase?
>
> Well, it's still worth investigating the original questions I posed...
>
> Craig

From what I can gather from my program, the positive frequencies are
those from 1:15. Then the frequencies from 16:30 are the complex
conjugates of the frequencies from 15:1. Therefore, I thinkt that IDL
is already accounting for the complex conjugate in the negative
frequencies, unless I am missing something.
Re: Complications with variance using FFTs [message #40138 is a reply to message #40126] Tue, 20 July 2004 06:54 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
olde_english33@hotmail.com (Eric) writes:
>
> Hello. First, I don't understand what you mean by "multiplied by
> exp(-phi)? Secondly, consider the following code instead:

I mean, that for a real signal, the Fourier components at negative
frequencies are the complex conjugate of those at positive
frequencies. Thus, EXP(IMAG*PHI) at positive frequencies becomes
EXP(-IMAG*PHI) at negative frequencies, for arbitrary PHI. Since you
are not changing to the complex conjugate at negative frequencies, I
think that's where your problem lies.

> Now I think all the code snipets are related correctly. I checked the
> the average variance of all the xf1[*,i] was equal to
> sum(avgspec1)/31.0 and that the average variance of xf2[*,i] was equal
> to sum(avgspec2)/31.0. This check held. It works if I don't throw in
> the symmetric random phase exp(e). Does this phase throw off the
> variance? Is there any way to account for inputting this random
> phase?

Well, it's still worth investigating the original questions I posed...

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Complications with variance using FFTs [message #40143 is a reply to message #40138] Mon, 19 July 2004 09:19 Go to previous message
olde_english33 is currently offline  olde_english33
Messages: 7
Registered: June 2004
Junior Member
Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> wrote in message news:<oniscn642i.fsf@cow.physics.wisc.edu>...
> olde_english33@hotmail.com (Eric) writes:
>
>> First I computed the FFT of a recorded time series. I then computed
>> the spectrum of this time series to keep the amplitudes of the
>> original data. I then wanted to tie in a random phase because I want
>> to give variables the same kind of shape when I inverse transform.
>> Here is a sample of my code:
> ...
>> My dilemma is that the average sample variances of the generated time
>> series ddd1 and ddd2 are nowhere close to the average sample variance
>> of the orginal time series xf1 and xf2. A colleague and I have
>> narrowed it down to the fact that we are multiplying the spectrum by a
>> random phase which is throwing off the variance but I don't know how
>> to counteract this problem. Can anyone help???
>
>
> Greetings, it's hard to comment, since your code snippets don't
> actually connect to each other, but I can ask some probing questions.
>
> Have you considered that for a pure real signal, the negative
> frequency components should actually be multiplied by exp(-phi)?
>
> Did you check that the magnitude of the Fourier components was
> preserved? And the corrolary, are you sure that IMAG is purely
> imaginary and doesn't have a real component?
>
> Good luck,
> Craig

Hello. First, I don't understand what you mean by "multiplied by
exp(-phi)? Secondly, consider the following code instead:

for i=0,12 do begin
Xf1[*,i]=fft(xf1[*,i]-mean(xf1[*,i]))*31.0
Xf2[*,i]=fft(xf2[*,i]-mean(xf2[*,i]))*31.0
specx1[*,i]=Xf1[*,i]*conj(Xf1[*,i])/31.0
specx2[*,i]=Xf2[*,i]*conj(Xf2[*,i])/31.0
endfor

for i=0,30 do begin
avgspec1=mean(spec1[i,*])
avgspec2=mean(spec2[i,*])
endfor

for j=0,99 do begin
rp=randomu(5*j,15)
e[0]=0.0
e[1:15]=rp
for k=0,14 do begin
e[30-k]=rp[k]
endfor
Hf1=avgspec1*exp(e)
Hf2=avgspec2*exp(e)
whtnoise[*,j]=(randomu(2*j+3,31)-0.5)*sqrt(12.0)
wn[*,j]=fft(whtnoise[*,j])
yf1[*,j]=Hf*wn[*,j]
yf2[*,j]=Hf*wn[*,j]
ddd1[*,j]=(fft(yf1[*,j],1))
ddd2[*,j]=(fft(yf2[*,j],1))
endfor

Now I think all the code snipets are related correctly. I checked the
the average variance of all the xf1[*,i] was equal to
sum(avgspec1)/31.0 and that the average variance of xf2[*,i] was equal
to sum(avgspec2)/31.0. This check held. It works if I don't throw in
the symmetric random phase exp(e). Does this phase throw off the
variance? Is there any way to account for inputting this random
phase?
Re: Complications with variance using FFTs [message #40161 is a reply to message #40143] Fri, 16 July 2004 14:21 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
olde_english33@hotmail.com (Eric) writes:

> First I computed the FFT of a recorded time series. I then computed
> the spectrum of this time series to keep the amplitudes of the
> original data. I then wanted to tie in a random phase because I want
> to give variables the same kind of shape when I inverse transform.
> Here is a sample of my code:
...
> My dilemma is that the average sample variances of the generated time
> series ddd1 and ddd2 are nowhere close to the average sample variance
> of the orginal time series xf1 and xf2. A colleague and I have
> narrowed it down to the fact that we are multiplying the spectrum by a
> random phase which is throwing off the variance but I don't know how
> to counteract this problem. Can anyone help???


Greetings, it's hard to comment, since your code snippets don't
actually connect to each other, but I can ask some probing questions.

Have you considered that for a pure real signal, the negative
frequency components should actually be multiplied by exp(-phi)?

Did you check that the magnitude of the Fourier components was
preserved? And the corrolary, are you sure that IMAG is purely
imaginary and doesn't have a real component?

Good luck,
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: ENVI: auto_wid_mng
Next Topic: Re: Keyboard Shortcuts

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:01:12 PDT 2025

Total time taken to generate the page: 0.00506 seconds