Fred,
As for FFT function that is implemented in 4.86 - yes it works with any
length (not only power of 2) and it provides both real and imaginary parts
Here is an excerpt from the documentation I have already written for it:
FFT( array, len = 0 )
performs FFT (Fast Fourier Transform) on last 'len' bars of the array, if len
is set to zero, then FFT is performed
on entire array. len parameter must be even.
Result:
function returns array which holds FFT bins for first 'len' bars. There are
len/2 FFT complex bins returned,
where bin is a pair of numbers (complex number): first is real part of the
complex number and second number
is the imaginary part of the complex number.
result = FFT( array, 256 );
where:
0th bin (result[0] and result[1]) represents DC component,
1st bin (result[1 ] and result[2]) represents real and imaginary parts of
lowest frequency range
and so on upto result[ len - 2 ] and result[ len - 1 ]
remaining elements of the array are set to zero.
FFT bins are complex numbers and do not represent real amplitude and phase. To
obtain amplitude and
phase from bins you need to convert inside the formula. The following code
snipplet does that:
ffc = FFT(data,Len);
for( i = 0; i < Len - 1; i = i + 2 )
{
amp[ i ] = amp[ i + 1 ] = sqrt(ffc[ i ]^ 2 + ffc[ i + 1 ]^2);
phase[ i ] = phase[ i + 1 ] = atan2( ffc[ i + 1], ffc[ i ] );
}
IMPORTANT note: input array for FFT must NOT contain any Null values. Use Nz()
function to convert Nulls to zeros
if you are not sure that input array is free from nulls.
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "Fred" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, October 06, 2006 4:47 PM
Subject: [amibroker] Re: Polynomial Trendlines
> TJ,
>
> I have long since had FFT capability in AFL as the algorithms are
> very straight forward and relatively simple to do in AFL. However
> FFT's typically require LOTS of data relative to the cycle lengths
> one is attempting to identify and do not provide particularly good
> resolution at the lower frequencies. From this perspective tools
> like MESA ( The algortihm, NOT the black box product ) provide much
> greater resolution with much less data.
>
> However, neither of these approaches is what I'm after at this
> juncture ... What I'm after is the ability to do trigonometric curve
> fitting in a similar way to what the PolyFit AFL I posted performs
> linear curve fitting i.e. via the solution of simultaneous
> equations. This involves some rather sophisticated ( at least from
> my perspective ) math which can be found for example in Appendix 6
> of J.M. Hurst's book. Since the discussion there is only about 3
> pages I'd be happy to post it or email it to anyone who has an
> interest and is so inclined if they'd like to read it and comment on
> how to implement it.
>
> Fred
>
> PS ... Some final thoughts about FFT's and their implementation in
> AB ... If you are going to provide this capability, please do so in
> a manner that one can take advantage of ALL the information that
> would be the product of performing an FFT i.e. both the real &
> imaginary arrays or a single array of complex numbers and the
> ability to deal with complex numbers in AFL. This is needed not
> only to get amplitudes at particular frequencies but also phase
> shift and power.
>
> PPS ... IMHO a DFT type implementation that does not require the
> data being anaylized to be a power of 2 in length would be superior
> to a Cooley-Tukey implementation even if run time is a little
> longer ...
>
> --- In [email protected], "Tomasz Janeczko" <[EMAIL PROTECTED]>
> wrote:
>>
>> For that you need Fourier transform and FFT is coming as a built
> in function in 4.86
>>
>> Best regards,
>> Tomasz Janeczko
>> amibroker.com
>> ----- Original Message -----
>> From: "Fred" <[EMAIL PROTECTED]>
>> To: <[email protected]>
>> Sent: Friday, October 06, 2006 3:48 AM
>> Subject: [amibroker] Re: Polynomial Trendlines
>>
>>
>> > Now if someone can take this method and/or AFL or at least
> provide a
>> > how to that takes us into Trigometric curve fitting and
> extrapolation
>> > i.e. the solution of simultaneous equations in the generalized
> format
>> > of a spectral model i.e. ...
>> >
>> > S ~ (a1 cos w1t + b1 sin w1t) + ... + (Am cos wm + bm sin wmt)
>> >
>> > Then we might have something fairly useful ...
>> >
>> > I suspect Gaussian Elimiation can be used for this as well, but
> I
>> > don't have the skill level to calculate the necessary matrix
> entries
>> > to get it down ...
>> >
>> > Any mathematicians out there ?
>> >
>> >
>> > --- In [email protected], "Fred" <ftonetti@> wrote:
>> >>
>> >> When stretch over enough data almost any order will become a
> pseudo
>> >> straight line ...
>> >>
>> >> By their nature a first order IS a straight line, 2nd U shape,
> 3rd
>> >> order sine wave etc ...
>> >>
>> >> Try highlighting a SMALLER segment of data by using the
> beginning
>> > and
>> >> ending range markers ...
>> >>
>> >>
>> >> --- In [email protected], "d_hanegan" <dhanegan@> wrote:
>> >> >
>> >> > Fred:
>> >> >
>> >> > Thanks for your posts and all of the information concerning
> the
>> >> > Polynomial Trendlines. When I run the code, I pretty much
> just
>> > get
>> >> > a straight green line; it does not fit my data. I thought I
> had
>> >> > read all of the posts. Am I missing something?
>> >> >
>> >> > Thanks.
>> >> >
>> >> > Dan
>> >> > --- In [email protected], "Fred" <ftonetti@> wrote:
>> >> > >
>> >> > > Be AWARE ... that was a hand picked image ... if you play
> with
>> >> > > PolyFit you will see that sometimes data fits the
>> > extrapolations,
>> >> > > sometimes it doesn't.
>> >> > >
>> >> > > The higher the order, the flakier the extrapolations are
> likely
>> >> to
>> >> > > become ...
>> >> > >
>> >> > > So ... Remember what it is ... a generator of an equation
> in
>> > the
>> >> > form
>> >> > >
>> >> > > Y = a + bx + cx^2 + ... + nx^(n-1)
>> >> > >
>> >> > > Where the coeeficients were pick to fit the data.
>> >> > >
>> >> > > IMHO what PolyFit is, epecially with very high orders is a
> very
>> >> > good
>> >> > > detrender of IN SAMPLE data, nothing more, nothing less ...
>> > That
>> >> > in
>> >> > > and of itself is a useful tool ... Gaussian Elimination can
>> > also
>> >> > be
>> >> > > the basis for some other things that are pretty decent when
> the
>> >> > order
>> >> > > is kept fairly low i.e. 3 or 4 ...
>> >> > >
>> >> > > --- In [email protected], "Ara Kaloustian" <ara1@>
>> > wrote:
>> >> > > >
>> >> > > > Polynomial TrendlinesFred,
>> >> > > >
>> >> > > > There have been a lot of posting on this subject. Your
> one
>> >> > image
>> >> > > however is a very powerful message of its potential.
>> >> > > >
>> >> > > > Now I have to go back and review all the post ... hoping
> to
>> >> find
>> >> > a
>> >> > > good reference to study.
>> >> > > >
>> >> > > > Anyone using it succesfully now?
>> >> > > >
>> >> > > > Ara
>> >> > > > ----- Original Message -----
>> >> > > > From: Fred Tonetti
>> >> > > > To: [email protected]
>> >> > > > Sent: Tuesday, October 03, 2006 3:32 PM
>> >> > > > Subject: [amibroker] RE: Polynomial Trendlines
>> >> > > >
>> >> > > >
>> >> > > > Oops .
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > > Meant to include this visual .
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > > Green is calculated . White is extrapolated .
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > > ----------------------------------------------------------
> ----
>> > --
>> >> -
>> >> > ---
>> >> > > ----------
>> >> > > > I am using the free version of SPAMfighter for private
>> > users.
>> >> > > > It has removed 8588 spam emails to date.
>> >> > > > Paying users do not have this message in their emails.
>> >> > > > Try SPAMfighter for free now!
>> >> > > >
>> >> > >
>> >> >
>> >>
>> >
>> >
>> >
>> >
>> >
>> >
>> > Please note that this group is for discussion between users only.
>> >
>> > To get support from AmiBroker please send an e-mail directly to
>> > SUPPORT {at} amibroker.com
>> >
>> > For other support material please check also:
>> > http://www.amibroker.com/support.html
>> >
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>>
>
>
>
>
>
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>
>
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/