home *** CD-ROM | disk | FTP | other *** search
- norng(r,p)
-
- /* this function generates a sequence of numbers normally */
- /* and randomly distributed over the interval -3 to 3 from */
- /* uniformly distributed random numbers by the method of linear */
- /* approximation to the inverse of the accumulative */
- /* normal distribution function. */
-
- float *r,*p;
-
- {
- int i;
- float z;
- static float s[5]={43.8596,11.3636,7.25689,2.891352,2.65887};
- static float x[6]={-3.01,-2.0,-1.5,-1.0,-.6,0.};
- static float y[6]={0.,.0228,.0668,.1357,.2743,.5};
-
- z = *r;
- strnum(&z);
- *r = z;
- *p = *r;
- i = 1;
- if (*p > 0.5) *p = 1. - *r;
- while(*p >= y[i])
- i ++;
- *p = ((*p - y[i-1]) * s[i-1] + x[i-1]);
- if (*r >= 0.5) *p = -*p;
- }