Message-ID: <004A396CB1B148B0939C94651C3DB4B7@Aragorn>
Date: 2009-03-04T16:04:18Z
From: Daniel Nordlund
Subject: How to generate fake population (ie. not sample) data?
In-Reply-To: <971536df0903040317r35f0283eh42297683315443bb@mail.gmail.com>
> -----Original Message-----
> From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com]
> Sent: Wednesday, March 04, 2009 3:17 AM
> To: Daniel Nordlund
> Cc: r-help at r-project.org
> Subject: Re: [R] How to generate fake population (ie. not
> sample) data?
>
> On Wed, Mar 4, 2009 at 2:48 AM, Daniel Nordlund
> <djnordlund at verizon.net> wrote:
> >> -----Original Message-----
> >> From: r-help-bounces at r-project.org
> >> [mailto:r-help-bounces at r-project.org] On Behalf Of CB
> >> Sent: Tuesday, March 03, 2009 10:05 PM
> >> To: David Winsemius
> >> Cc: r-help at r-project.org
> >> Subject: Re: [R] How to generate fake population (ie. not
> >> sample) data?
> >>
> >> My understanding is that rnorm(n, x, s) will give me an
> n-sized sample
> >> from an (x, s) normal distribution. So the vector returned
> will have a
> >> mean from the sampling distribution of the mean. But what
> I want is a
> >> set of n numbers literally with a mean of x and sd of s.
> >>
> >> I am at the very beginning of my R journey, so my
> apologies if this is
> >> a particularly naive enquiry.
> >>
> >> 2009/3/4 David Winsemius <dwinsemius at comcast.net>:
> >> > In what ways is rnorm not a satisfactory answer?
> >> >
> >> > --
> >> > David Winsemius
> >> >
> >> > On Mar 3, 2009, at 9:33 PM, CB wrote:
> >> >
> >> >> This seems like it should be obvious, but searches I've
> >> tried all come
> >> >> up with rnorm etc.
> >> >>
> >> >> Is there a way of generating normally-distributed
> 'population' data
> >> >> with known parameters?
> >> >>
> >> >> Cheers, CB.
> >> >>
> >
> > Something like this may help get you started.
> >
> > std.pop <- function(x,mu,stdev){
> > ?((x-mean(x))/sd(x)*stdev)+mu
> > ?}
>
> Note the scale function, i.e. the above can also be written:
>
> stdev * scale(x) + mu
>
>
Gabor,
Thanks for pointing out the scale() function for the OP. I suspected that
something like that existed, but in a (very) quick look around didn't find
it.
Dan
Daniel Nordlund
Bothell, WA USA