Re: [R] Question

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Tue 13 Dec 2005 - 23:15:14 EST

Davia Cox 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.

Yes, that's what set.seed is intended to do... otherwise don't use set.seed (and make your work unreproducible).

> My question is in order to run a true random sample,

We have to disappoint you: Your computer cannot generate "true random samples".

 > wouldn't I have
> to use the runif function? And then deliminate the sample to show the

No, if you want integers, the sample above fits perfectly well.

> numbers that lie between 4 and 6? If that's the case, how do I do that?

Is this a homework question?

Uwe Ligges

>
> Davia S. Cox
> 517-575-8031 cell
> davia.cox@gmail.com
>
> "Human potential, though not always apparent, is there waiting to be
> discovered and invited forth." -William W. Purkey
>
> ______________________________________________
> 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



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:29:18 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:35 EST