[R] rnorm() converted to daily

Karl Ove Hufthammer Karl.Hufthammer at math.uib.no
Fri Apr 17 10:11:27 CEST 2009


Ken-JP:

> Does this have something to do with biases due to the relationship between
> population and sample-estimates as a function of n samples and sd?  Or am
> I doing something wrong?
> 
> -----------------------------------------------------------------------
> 
> set.seed( 1 );
> x <- mean( rnorm( 100000, mean=0.08, sd=0.25 ));
> set.seed( 1 );
> y <- mean( rnorm( 100000, mean=(0.08/252), sd=(0.25/sqrt(252)) )) * 252;
> set.seed( 1 );
> z <- mean( rnorm( 100000, mean=(0.08/252), sd=0.001 )) * 252;

Yes, you’re doing something wrong.

While it is true¹ that rnorm(n, a, b) will give the same results as
rnorm(n, 0, 1) * b + a, it is *not* true that the above calculations
would return the same numbers. That’s the reason the the means 
differ.

¹ True in practice, but not documented as far as I can see, so you
  should not depend on it.

-- 
Karl Ove Hufthammer




More information about the R-help mailing list