【问题标题】:Speed up Computation加速计算 【发布时间】:2021-01-19 21:30:59 【问题描述】: 我有这个代码;它很慢,我希望它更快(即在没有 for 循环的情况下写入一行) n = 1000000 x = numeric(n) for (i in 1:n) x[i] = rpois(1, 3) + rpois(1, 5) 【问题讨论】: 标签: r 【解决方案1】: rpois 函数是矢量化的,所以这应该适合你: n = 1000000 x <- rpois(n, 3) + rpois(n, 5) 【讨论】: