PureBytes Links
Trading Reference Links
|
Hi Howard,
Thanks. It is a coincidence that you came out with a value of 50 for
the period which I happen to like the most.
I was investigating how to get a Z-Score given the percentile. I am
aware of the formula for Z-Score. It is also available in the AFL
Formula Library and is called the Bollinger Oscillator.
Schmeiser (1979) came up with the following simple formula for p >
0.5:
z = {p ^ 0.135 - (1-p) ^ 0.135} / 0.1975
According to a table in Shore (1982), it is accurate to two digits at
p = 0, 0.4, 0.8, ..., which may be good enough.
Here are references to literature where the the focus is on
simplicity of the result rather than accuracy:
Bailey, B. (1981), Applied Statistics, 30(3), 275-276.
Page, E. (1977), Applied Statistics, 26(1), 75.
Schmeiser, B. W. (1979) Applied Statistics, 28, 175-176.
Shore, H., (1982) Applied Statistics, 31(2), 108-114.
Here is one in perl
Pz($val) is the "forward" function which returns percentile for an
input in the [-6, 6] z-score interval
sub Cz {#bisection search using the monotonity of Pz
my $p = shift; #percentile input 0.0 - 1.0
my $EPSILON = 0.000001; #Accuracy of approximation
my $minz = -6; #minimum value
my $maxz = 6; #maximum value
my $zval = 0; #first value
if ($p <= 0.0) {return $minz;}
else {if ($p >= 1.0) {return $maxz;}}
while (($maxz - $minz) > $EPSILON) {
if (Pz($zval) > $p) {$maxz = $zval;}
else {$minz = $zval;}
$zval = ($maxz + $minz) / 2;
}
return $zval; #z score output
}
Pal
--- In amibroker@xxxxxxxxxxxxxxx, "Howard Bandy" <howardbandy@xxxx>
wrote:
> Hi Pal --
>
> There is one interpretation of the Z-Score that takes an
observation from a
> population and returns a Z-Score statistic, where the Z-Score is a
> measurement of the number of standard deviations that that specific
> observation deviates from the mean. If this is the interpretation
you
> intend, the following afl code returns the Z-Score of the Close of
the most
> recent 50 days of an end-of-day price series and plots it. Copy
this code
> and paste it into Indicator Builder.
>
>
> //-------------------------
>
> // ZScore of Close
> //
>
> ZLen = 50;
> ZScore = (C-MA(C,ZLen))/StDev(C,ZLen);
>
> Plot(C,"C",colorBlack,style=styleCandle);
>
> Plot(ZScore,"ZScore",colorBlue,styleOwnScale|styleNoLabel,-3,3);
>
> Plot(0,"",colorRed,styleOwnScale|styleNoLabel,-3,3);
> Plot(-2.0,"", colorRed,styleOwnScale|styleNoLabel,-3,3 );
> Plot(2.0,"", colorRed,styleOwnScale|styleNoLabel,-3,3);
>
> //-------------------------
>
> Note that most of the Closes (95 percent, on average) will have
ZScore
> values between -2.0 and +2.0.
>
> My apologies if I misinterpreted your request.
>
> Howard
>
> /////-----------------------------
>
>
> Date: Fri, 19 Sep 2003 19:01:08 -0000
> From: "palsanand" <palsanand@xxxx>
> Subject: Z-Score
>
> Hi,
>
> I was looking for an algorithm that will tell me the z-score of a
> given percentile. In other words, I was looking for an algorithm
> that will replicate a reverse lookup in a normal distribution table.
>
> Abramowitz & Stegun is my friend ("Handbook of Mathematical
> Functions"). Formula 26.2.22 gives an approximation in z accurate to
> within 3e-3, and formula 26.2.23 gives a more complicated but more
> accurate formula.
>
> 26.2.22 says this (in pseudo-Fortran). p appears to be the
> *upper*-tail probability (ie. p=P(Z>z)) and has to be less than 0.5
> for this to work. (If not, call the function with argument 1-p and
> put
> a minus sign on the result.)
>
> t=sqrt(ln(1/p**2)) [ p squared ]
> a0=2.30753
> a1=0.27061
> b1=0.99229
> b2=0.04481
> z=t-(a0+a1*t)/(1-t*(b1+b2*t))
>
> The problem is to implement this efficiently in AB. Ay ideas?
> Thanks,
> Pal
------------------------ Yahoo! Groups Sponsor ---------------------~-->
ReplayTV: Control live television
Special Sale: 50% off ReplayTV
CNet Ranked #1 over Tivo!
http://us.click.yahoo.com/aUMW7B/A6qGAA/ySSFAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
|