Dear All,

I need to write an R function which computes values of  Probabilities for
the (standard) normal distribution, ІЕ(z) for z > 0 by summing this power
series. (We should accumulate terms until the sum doesn't change). I also
need to make the function work for vector of values z.

The initial fomular is

 

ІЕ(z) = ( 1/ sqrt(2Іа) )* Ёв e^(-t^2/2)dt       (Ёв is from -Ёо, z)

         = 1/ 2 + ( 1/ sqrt(2Іа) )* Ёв e^(-t^2/2)dt     (Ёв is from 0 to z)

 

I can substituting x = -t^2/2 into the series expansion for the exponential
function

 

 

e^x = ЁЦ x^n/n!         (ЁЦ is from n=0 to Ёо)

 

I can obtain the series

 

e^(-t^2/2) = ЁЦ (-1)^k*t^2k / 2^k*k!       (ЁЦ is from n=0 to Ёо)

 

 

 

This series can be integrated term by term to obtain the formula

 

ІЕ(z) = 1/ 2 + ( 1/ sqrt(2Іа) ) * ЁЦ (-1)^k*z^(2k+1) / (2^k*k! *(2k+1))
(ЁЦ is from n=0 to Ёо)

 

 

I know how to write the R function for exponential function e^x 

 

 expf  = function (x)

                {

                x=ifelse((neg=(x<0)),-x,x)

                n=0;term=1

                 oldsum=0; newsum=1

                while(any(newsum != oldsum)) {

                oldsum=newsum

                n=n+1

                term = term*x/n

                newsum = newsum+term}

                ifelse(neg, 1/newsum, newsum)

                }

 

 

I know it will be similar to the above coding, but I donЁЏt know exactly how
should we  modify the above coding in order to get Probabilities for the
(standard) normal distribution, ІЕ(z) for z > 0.  

 

Can anybody advise me on this??

 

 

Thanks a lot.

 

Rene.

 

 

 

 

 


	[[alternative HTML version deleted]]


