[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Chaos:Introductory AFL notes



PureBytes Links

Trading Reference Links


Tomasz,
Thank you for the valuable hints.
On the other side, have a look at
http://finance.groups.yahoo.com/group/amibroker/message/71369
"...Sometimes compact code could make the mechanism very hard to 
understand...."
The golden section for a public presentation is not always easy.
I thought it would be better to give the analytic form of the 
repetitive use of a function [since it was the first time we discuss 
this subject] and then give more elegant forms [following your 
upcoming newsletter perhaps].
Dimitris

--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
wrote:
> Hello,
> 
> You can also use iterative execution (results in shorter code)
> 
> function fN( N, x )
> {
>    for( i = 0; i < N; i++ )
>    {
>      x= x^2+1/4;
>    }
>   
>    return x;
> }
> 
> and call it 
> fN( 1000, 0.75 ); // this is equivalent to f1000( 0.75 )
> 
> Also to reduce time needed to compute you should avoid calling
> the same function with the same parameters twice (1st time in 
WriteIf and
> 2nd time in WriteVal) when it is only necessary to call it once: 
> 
> function fN( N, x ) 
> { 
>    for( i = 0; i < N; i++ ) 
>    { 
>      x= x^2-3/4; 
>    } 
>    
>    return x; 
> } 
> 
> Title = ""; 
> for(i=-1.75;i<2;i=i+0.25) 
> { 
> Title=Title+"\ni="+ 
> WriteIf(i>=0," ","")+WriteVal(i,1.2)+ 
> StrFormat("%6.2f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f", 
> i, 
> fN( 1, i), fN( 5, i), fN( 10, i), fN( 50, i), fN( 100, i), fN( 500, 
i), fN( 1000, i)); 
> } 
> 
> 
> This code executes in 0.5 second or less (4 times faster).
> This simple example shows the how much speed can be gained by 
making the code
> optimal.
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Wednesday, October 06, 2004 8:52 AM
> Subject: [amibroker] Chaos:Introductory AFL notes
> 
> 
> > 
> > 
> > AFL structure helps to reproduce the tables of
> > http://www.hypertextbook.com/chaos/11.shtml
> > The initial function is applied 1, 5, 10, 50, 100, 500 and 1000 
times 
> > [!!]
> > In an Indicator builder window paste the
> > 
> > Title="The orbits of 9 seeds of the f(x)=x^2+1/4"; 
> > function f1(x)
> > {return x^2+1/4;}
> > function f5(x)
> > {return f1(f1(f1(f1(f1(x)))));}
> > function f10(x)
> > {return f5(f5(x));}
> > function f50(x)
> > {return f10(f10(f10(f10(f10(x)))));}
> > function f100(x)
> > {return f50(f50(x));}
> > function f500(x)
> > {return f100(f100(f100(f100(f100(x)))));}
> > function f1000(x)
> > {return f500(f500(x));}
> > for(i=-1;i<=1;i=i+0.25)
> > {
> > Title=Title+"\ni="+
> > WriteIf(i>=0," ","")+WriteVal(i,1.2)+
> > WriteIf(f1(i)>0,"   ","  ")+WriteVal(f1(i),1.3)+
> > WriteIf(f5(i)>0,"   ","  ")+WriteVal(f5(i),1.3)+
> > WriteIf(f10(i)>0,"   ","  ")+WriteVal(f10(i),1.3)+
> > WriteIf(f50(i)>0,"   ","  ")+WriteVal(f50(i),1.3)+
> > WriteIf(f100(i)>0,"   ","  ")+WriteVal(f100(i),1.3)+
> > WriteIf(f500(i)>0,"   ","  ")+WriteVal(f500(i),1.3)+
> > WriteIf(f1000(i)>0,"   ","  ")+WriteVal(f1000(i),1.3);
> > }
> > 
> > and, with a few changes, in a new IB window, paste the
> > 
> > Title="The orbits of 15 seeds of the f(x)=x^2-3/4"; 
> > function f1(x)
> > {return x^2-3/4;}
> > function f5(x)
> > {return f1(f1(f1(f1(f1(x)))));}
> > function f10(x)
> > {return f5(f5(x));}
> > function f50(x)
> > {return f10(f10(f10(f10(f10(x)))));}
> > function f100(x)
> > {return f50(f50(x));}
> > function f500(x)
> > {return f100(f100(f100(f100(f100(x)))));}
> > function f1000(x)
> > {return f500(f500(x));}
> > for(i=-1.75;i<2;i=i+0.25)
> > {
> > Title=Title+"\ni="+
> > WriteIf(i>=0," ","")+WriteVal(i,1.2)+
> > WriteIf(f1(i)>0,"   ","  ")+WriteVal(f1(i),1.3)+
> > WriteIf(f5(i)>0,"   ","  ")+WriteVal(f5(i),1.3)+
> > WriteIf(f10(i)>0,"   ","  ")+WriteVal(f10(i),1.3)+
> > WriteIf(f50(i)>0,"   ","  ")+WriteVal(f50(i),1.3)+
> > WriteIf(f100(i)>0,"   ","  ")+WriteVal(f100(i),1.3)+
> > WriteIf(f500(i)>0,"   ","  ")+WriteVal(f500(i),1.3)+
> > WriteIf(f1000(i)>0,"   ","  ")+WriteVal(f1000(i),1.3);
> > }
> > 
> > Glenn Elert, the author of this interesting book, writes :"...if 
you 
> > wait long enough..."
> > The AFL time is ~2sec and it is not bad at all !!
> > 
> > Dimitris
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Check AmiBroker web page at:
> > http://www.amibroker.com/
> > 
> > Check group FAQ at: 
http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > Yahoo! Groups Links
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/