[R] Normal Distribution Quantiles

David Winsemius dwinsemius at comcast.net
Sat Jan 8 14:56:20 CET 2011


On Jan 8, 2011, at 6:56 AM, Rainer Schuermann wrote:

> This is probably embarrassingly basic, but I have spent quite a few  
> hours in Google and RSeek without getting a clue - probably I'm  
> asking the wrong questions...
>
> There is this guy who has decided to walk through Australia, a total  
> distance of 4000 km. His daily portion (mean) is 40km with an sd of  
> 10 km. I want to calculate the number of days it takes to arrive  
> with 80, 90, 95, 99% probability.
> I know how to do this manually, eg. for 95%
> $\Phi \left( \frac{4000-40n}{10 \sqrt{n}}  \right) \leq 0.05$
> find the z score...
>
> but how would I do this in R? Not qnorm(), but what is it?

Sounds like homework, which is not an encouraged use of the Rhelp  
list. You can either do it in theory or you can simulate it. Here's a  
small step toward a simulation approach.

 > cumsum(rnorm(100, mean=40, sd=10))
   [1]   41.90617   71.09148  120.55569  159.56063  229.73167   
255.35290  300.74655
snipped
  [92] 3627.25753 3683.24696 3714.11421 3729.41203 3764.54192  
3809.15159 3881.71016
  [99] 3917.16512 3932.00861
 > cumsum(rnorm(100, mean=40, sd=10))
   [1]   38.59288   53.82815  111.30052  156.58190  188.15454   
207.90584  240.64078
snipped
  [92] 3776.25476 3821.90626 3876.64512 3921.16797 3958.83472  
3992.33155 4045.96649
  [99] 4091.66277 4134.45867

The first realization did not make it in the expected 100 days so  
further efforts should extend the simulation runs to maybe 120 days.  
The second realization had him making it on the 98th day. There is an  
R replicate() function available once you get a function running that  
will return a specific value for an instance. This one might work:
 > min(which(cumsum(rnorm(120, mean=40, sd=10)) >= 4000) )
[1] 97

If you wanted a forum that does not explicitly discourage homework and  
would be a better place to ask theory and probability questions, there  
is CrossValidated:
http://stats.stackexchange.com/faq

-- 
David.

>
> Thanks in advance,
> and apologies for the level of question...
> Rainer
>
> ______________________________________________
> R-help at 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list