Skip to content

sum(rnorm(n)), calculate more efficiently

2 messages · Karsten D Bjerre, Deepayan Sarkar

#
I want to simulate the end point of a one-dimensional brownian motion going on for many timesteps (n very large). 
Can this be done more efficiently than (effect of drift excluded): 
endpoint <- sum(rnorm(n))

Thanks in advance!
Karsten



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Wednesday 20 November 2002 09:58 am, Karsten D Bjerre wrote:
Do you really mean a one-dimensional random walk ?

The sum of n independent N(0,1) variables is N(0, n), so if you are interested 
in only the endpoint, you might as well use that fact.

Deepayan


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._