On 07-Apr-05 Daniel E. Bunker wrote:
> Hi All,
>
> I need to sample a vector ("old"), with replacement, up to the point
> where my vector of samples ("new") sums to a predefined value
> ("target"), shortening the last sample if necessary so that the total
> sum ("newsum") of the samples matches
Hi,
sample() takes a "replace" argument, so you can take large samples,
with replacement, like this: (In the sample() call, the
50*target/mean(old) should make it sample 50 times more than likely.
This means the while loop will probably get executed only once. This
could be tuned easily, and ther
Hi All,
I need to sample a vector ("old"), with replacement, up to the point
where my vector of samples ("new") sums to a predefined value
("target"), shortening the last sample if necessary so that the total
sum ("newsum") of the samples matches the predefined value.
While I can easily do this