Hello, How do I sample observations with replacement from a normal distribution with a specific mean and s.d? (I want to see the sample, not only the statistic.) Thank you, Sigalit. [[alternative HTML version deleted]]
Did you consider ?rnorm or ?sample? Petr petr.pikal at precheza.cz r-help-bounces at r-project.org napsal dne 15.01.2008 10:17:15:> Hello, > How do I sample observations with replacement from a normal distribution > with a specific mean and s.d? > (I want to see the sample, not only the statistic.) > Thank you, > Sigalit. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
See rnorm(). If you are sampling from a continuous normal distribution, it makes no sense to define a sample with replacement, because the probability of sampling twice the same number is zero. Julian sigalit mangut-leiba wrote:> Hello, > How do I sample observations with replacement from a normal distribution > with a specific mean and s.d? > (I want to see the sample, not only the statistic.) > Thank you, > Sigalit. > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.
I used sample like you suggested. Thank you, Sigalit. On 1/15/08, Zhengyang Sun <kirsten1209@gmail.com> wrote:> > Hi Sigalit, > use ?sample. hope the example below answers your question: > > aa<-rnorm(20,3,0.6) > > aa > [1] 2.348048 2.535320 2.773491 3.051137 2.574342 3.636812 3.267405 > 2.475192 > [9] 3.327903 3.539000 1.962290 2.423167 2.604629 2.929914 3.110048 > 3.673091 > [17] 3.316083 3.545558 3.103457 2.551673 > > sample(aa,30,replace=TRUE) > [1] 2.475192 2.551673 2.535320 3.545558 3.673091 3.316083 2.348048 > 3.636812 > [9] 2.574342 3.051137 2.574342 2.574342 3.539000 2.535320 3.539000 > 3.545558 > [17] 3.051137 3.636812 2.475192 2.348048 3.051137 2.535320 3.316083 > 2.348048 > [25] 2.929914 3.539000 3.110048 2.773491 1.962290 2.475192 > > then you can do the rest, eg, take mean, sum, etc of the resampled data > > > 2008/1/15, sigalit mangut-leiba <smangut@gmail.com>: > > > > Hello, > > How do I sample observations with replacement from a normal distribution > > with a specific mean and s.d? > > (I want to see the sample, not only the statistic.) > > Thank you, > > Sigalit. > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > 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<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > > >[[alternative HTML version deleted]]