Hi Group,
Can anyone explain the vast differences between the Variance.A and
Variance.B or Variance.C below?
From the last 4 calls, my problem appears to be in the x^2 terms. Am
I just having a bad day?
I get similar performance with rhyper and others as well as the rnorm
used here.
thanks,
john
> xx <- rnorm( 50000, 1, 5)
> pp <- dnorm( xx , 1, 5)
> pp <- pp / sum( pp )
> paste( 'Variance.A = ', round( var( xx ), 2 ) , sep='')
[1] "Variance.A = 24.97"
> paste( 'Variance.B = ', round( sum(xx^2 * pp ) - (sum( xx*pp
) )^2, 2 ) , sep='' )
[1] "Variance.B = 12.52"
> paste( 'Variance.C = ', round( sum( (xx - sum( xx * pp ) )^2
* pp), 2 ) , sep='' )
[1] "Variance.C = 12.52"
> paste( 'Mean.A = ', round( sum( xx * pp ), 2 ) , sep=''
[1] "Mean.A = 0.99"
> paste( 'Mean.B = ', round( mean( xx ), 2 ) , sep='')
[1] "Mean.B = 1"
> paste( 'E{xx^2}.A = ', round( var( xx ) + mean( xx )^2, 2 ) , sep='' )
[1] "E{xx^2}.A = 25.97"
> paste( 'E{xx^2}.B = ', round( sum( xx^2 * pp) , 2 ) , sep='' )
[1] "E{xx^2}.B = 13.49"
John Fennick
jhf2@bellsouth.net
alt: j.fennick@ieee.org
Tel: 770 949-9132
7045 Fletcher Drive
Winston, GA 30187
USA
|