20, 2009 10:02 PM
> > To: milton ruser; Chloe Smith
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Problems with sample variance
> >
> > Thanks Milton - I misread Chloe's original question.
> >
> > nSims <- 1000
> > sampSiz <- 15
> > my
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Alspach
> Sent: Wednesday, May 20, 2009 10:02 PM
> To: milton ruser; Chloe Smith
> Cc: r-help@r-project.org
> Subject: Re: [R] Problems with sample
-boun...@r-project.org] On Behalf Of milton ruser
> Sent: Thursday, 21 May 2009 4:30 p.m.
> To: Chloe Smith
> Cc: r-help@r-project.org
> Subject: Re: [R] Problems with sample variance
>
> Hi Chloe,
>
> Try this:
>
> NUMBER.OF.RUNS<-10 #change here
> for (NR in 1:
Hi Chloe,
Try this:
NUMBER.OF.RUNS<-10 #change here
for (NR in 1:NUMBER.OF.RUNS)
{
number.simulation<-1000
sample.size=15;
variance.list<-NULL
for(i in 1:number.simulation)
{
mysample<-rnorm(sample.size)
variance.list<- c(variance.list, var(mysample))
} #i
hist(variance.list)
} #NR
Tena koe Chloe
Try
var(r)
BTW, it is better to use more than single letters in name your objects
to reduce the chance of conflicting with a standard R object.
HTH ...
Peter Alspach
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On B
Chloe Smith wrote:
>
>
> [snip]
>
> what I got was just the variance for the last sample i.e. the 1000th
> sample
>
> but what I want is 1000 variance.
>
>
m=1000;n=15
r<-matrix(rnorm(m*n),nrow=m)
apply(r,1,var)
--
View this message in context:
http://www.nabble.com/Problems-with-samp
6 matches
Mail list logo