Re: [R] Question

From: Sean Davis <sdavis2_at_mail.nih.gov>
Date: Tue 13 Dec 2005 - 23:14:47 EST

On 12/13/05 6:20 AM, "Davia Cox" <davia.cox@gmail.com> wrote:

> Hello,
>
> I have a problem that I am trying to solve and I am not sure how to
> do it in R.
>
> Suppose, that 16 numbers are choosen at random from 0 to 9, what's
> the probability that their average will be between 4 and 6. I typed
> the following code:
>
> set.seed(100)
> sample(0:9, 16, replace =TRUE)
> [1] 3 2 5 0 4 4 8 3 5 1 6 8 2 3 7 6
>
> Is what I got, however I realize the set.seed function locks in the
> number I get every time.

Just don't use set.seed() before every run (unless you want to always get the same answers). Set.seed() is available to allow you to generate reproducible results, so not using it means that you will get a different set of random numbers every time you run your "sample" from above.

Sean



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Dec 14 00:26:34 2005

This archive was generated by hypermail 2.1.8 : Wed 14 Dec 2005 - 02:33:51 EST