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

[amibroker] Re: Code for CUMULATIVE normal distribution



PureBytes Links

Trading Reference Links

Thanks Howard,

This very much looks like the list of Z-scores I had seen before, as 
mentioned in my mail yesterday ! 

Still, your function is equal to Excel's NORMSINV(p) function which I 
already got. Iow, I have functions to translate a standardized z-
score into a prob and vice versa. Using the A&S mentioned below, I 
can get probs for values where Mu and SD are not zero, resp 1. 
However, they do not match XL's values.

Thx anyway, I'll continue digging.

PS

--- In amibroker@xxxxxxxxxxxxxxx, "Howard B" <howardbandy@xxx> wrote:
>
> Hi --
> 
> How will you be using the distribution?
> 
> How much accuracy do you need?
> 
> Here is afl code that will initialize an array with the Cumulative
> Distribution Function of the Normal Distribution.
> 
> //---------------------------
> 
> //    InitializeNormalCDF.afl
> //
> function InitializeNormalCDF()
> //    Initialize the array that holds the coefficients
> //    for the Normal Cumulative Distribution function.
> {
>     NormCDF[0] = -3.090;
>     NormCDF[1] = -2.326;
>     NormCDF[2] = -2.053;
>     NormCDF[3] = -1.881;
>     NormCDF[4] = -1.751;
>     NormCDF[5] = -1.645;
>     NormCDF[6] = -1.555;
>     NormCDF[7] = -1.476;
>     NormCDF[8] = -1.405;
>     NormCDF[9] = -1.341;
>     NormCDF[10] = -1.282;
>     NormCDF[11] = -1.227;
>     NormCDF[12] = -1.175;
>     NormCDF[13] = -1.126;
>     NormCDF[14] = -1.080;
>     NormCDF[15] = -1.036;
>     NormCDF[16] = -0.994;
>     NormCDF[17] = -0.954;
>     NormCDF[18] = -0.915;
>     NormCDF[19] = -0.878;
>     NormCDF[20] = -0.842;
>     NormCDF[21] = -0.806;
>     NormCDF[22] = -0.772;
>     NormCDF[23] = -0.739;
>     NormCDF[24] = -0.706;
>     NormCDF[25] = -0.674;
>     NormCDF[26] = -0.643;
>     NormCDF[27] = -0.613;
>     NormCDF[28] = -0.583;
>     NormCDF[29] = -0.553;
>     NormCDF[30] = -0.524;
>     NormCDF[31] = -0.496;
>     NormCDF[32] = -0.468;
>     NormCDF[33] = -0.440;
>     NormCDF[34] = -0.412;
>     NormCDF[35] = -0.385;
>     NormCDF[36] = -0.358;
>     NormCDF[37] = -0.332;
>     NormCDF[38] = -0.305;
>     NormCDF[39] = -0.279;
>     NormCDF[40] = -0.253;
>     NormCDF[41] = -0.228;
>     NormCDF[42] = -0.202;
>     NormCDF[43] = -0.176;
>     NormCDF[44] = -0.151;
>     NormCDF[45] = -0.126;
>     NormCDF[46] = -0.100;
>     NormCDF[47] = -0.075;
>     NormCDF[48] = -0.050;
>     NormCDF[49] = -0.025;
>     NormCDF[50] = 0.000;
>     NormCDF[51] = 0.025;
>     NormCDF[52] = 0.050;
>     NormCDF[53] = 0.075;
>     NormCDF[54] = 0.100;
>     NormCDF[55] = 0.126;
>     NormCDF[56] = 0.151;
>     NormCDF[57] = 0.176;
>     NormCDF[58] = 0.202;
>     NormCDF[59] = 0.228;
>     NormCDF[60] = 0.253;
>     NormCDF[61] = 0.279;
>     NormCDF[62] = 0.305;
>     NormCDF[63] = 0.332;
>     NormCDF[64] = 0.358;
>     NormCDF[65] = 0.385;
>     NormCDF[66] = 0.412;
>     NormCDF[67] = 0.440;
>     NormCDF[68] = 0.468;
>     NormCDF[69] = 0.496;
>     NormCDF[70] = 0.524;
>     NormCDF[71] = 0.553;
>     NormCDF[72] = 0.583;
>     NormCDF[73] = 0.613;
>     NormCDF[74] = 0.643;
>     NormCDF[75] = 0.674;
>     NormCDF[76] = 0.706;
>     NormCDF[77] = 0.739;
>     NormCDF[78] = 0.772;
>     NormCDF[79] = 0.806;
>     NormCDF[80] = 0.842;
>     NormCDF[81] = 0.878;
>     NormCDF[82] = 0.915;
>     NormCDF[83] = 0.954;
>     NormCDF[84] = 0.994;
>     NormCDF[85] = 1.036;
>     NormCDF[86] = 1.080;
>     NormCDF[87] = 1.126;
>     NormCDF[88] = 1.175;
>     NormCDF[89] = 1.227;
>     NormCDF[90] = 1.281;
>     NormCDF[91] = 1.341;
>     NormCDF[92] = 1.405;
>     NormCDF[93] = 1.476;
>     NormCDF[94] = 1.555;
>     NormCDF[95] = 1.645;
>     NormCDF[96] = 1.751;
>     NormCDF[97] = 1.881;
>     NormCDF[98] = 2.054;
>     NormCDF[99] = 2.326;
>     NormCDF[100] = 3.090;
>     return(Null);
> }
> //Figure 22.5 Initialization of CDF
> //--------------------------
> 
> A fairly detailed discussion about how to use it, including an 
example, is
> on pages 295 through 305 of my book -- Quantitative Trading Systems.
> 
> Thanks,
> Howard
> www.quantitativetradingsystems.com
> 
> 
> 
> 
> On 5/30/07, vlanschot <vlanschot@xxx> wrote:
> >
> >   I have various functions for normal distributions, but for some 
reason
> > none seem to be able to replicate Excel's NORMDIST
(x,mean,stdev,TRUE).
> >
> > I've applied the Abramowitz & Stegun approximation to calculate 
the
> > cumulative normal function. However, the pdf agrees with Excel's
> > NORMDIST(x,mean,stdev,FALSE), but the cdf does not match its 
NORMDIST
> > (x,mean,stdev,TRUE).
> >
> > I did read there have been criticisms expressed as to the 
accuracy of
> > XL's approximations, but doubt this is applicable in this case.
> >
> > Any suggestions appreciated.
> >
> > PS
> >
> >  
> >
>




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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/