On Aug 19, 2009, at 7:04 AM, Rene wrote:

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.

Two problems:
One, this appears to be a homework exercise.

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)

Two, you are posting in HTML mail and the characters that you may think we should be seeing reading as Greek letters including I presume capital sigma for summation are .... not displayed properly.



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]]

______________________________________________

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to