如果我有一个包含随机性的操作(让我们称之为operation_with_randomness(number)),并且我希望它运行x次
> b <- rep(operation_with_randomness(number), x)我得到了
> b
1.5472491 1.5472491 1.5472491 1.5472491 1.5472491 1.5472491 ...是否有任何聪明的方法(例如,不是循环结构),每次运行operation_with_randomness(number),以获得一个b向量,其中包含x单独运行的值?
发布于 2011-02-16 10:23:38
可能会遇到以下情况:
> z <- replicate(10, runif(1))
> z
[1] 0.762778299 0.541601960 0.654238258 0.026323048 0.532011084 0.905059722 0.328891040 0.297307167 0.004157573 0.507231966https://stackoverflow.com/questions/5015109
复制相似问题