# [R] Variance Computing- - HELP!!!!!!!!!!!!!!!!!!

Tony Plate tplate at blackmesacapital.com
Tue Aug 19 20:11:36 CEST 2003

```Perhaps you were trying for "as sample size increases, variance *of the
mean* decreases" (a least when variance is finite).  If you swap "mean" and
"var" in your code, I think you will get what you are looking for.

-- Tony Plate

At Tuesday 05:42 PM 8/19/2003 +0000, Padmanabhan, Sudharsha wrote:

>Hello,
>
>I am running a few simulations for clinical trial anlysis. I want some help
>regarding the following.
>
>We know trhat as the sample size increases, the variance should decrease, but
>I am getting some unexpected results. SO I ran a code (shown below) to check
>the validity of this.
>
>large<-array(1,c(1000,1000))
>small<-array(1,c(100,1000))
>for(i in 1:1000){large[i,]<-rnorm(1000,0,3)}
>for(i in 1:1000){small[i,]<-rnorm(100,0,3)}}
>yy<-array(1,100)
>for(i in 1:100){yy[i]<-var(small[i,])}
>y1y<-array(1,1000)
>for(i in 1:1000){y1y[i]<-var(large[i,])}
>mean(yy);mean(y1y);
>[1] 8.944
>[1] 9.098
>
>
>This shows that on an average,for 1000 such samples of 1000 Normal numbers,
>the variance is higher than that of a 100 samples of 1000 random numbers.
>
>Why is this so?
>
>
>
>Thanks.
>
>Regards
>
>~S.
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help

```