On Tue, 8 May 2007, Victor Gravenholt wrote:
As a part of a simulation, I need to sample from a large vector repeatedly.
For some reason sample() builds up the memory usage ( 500 MB for this
example) when used inside a for loop as illustrated here:
X - 1:10
P - runif(10)
for(i in
As a part of a simulation, I need to sample from a large vector repeatedly.
For some reason sample() builds up the memory usage ( 500 MB for this
example) when used inside a for loop as illustrated here:
X - 1:10
P - runif(10)
for(i in 1:500) Xsamp - sample(X,3,replace=TRUE,prob=P)