【发布时间】:2019-01-19 17:58:19
【问题描述】:
我试图首先从mother 正态分布中提取所有值<= -4(称为p1)。然后,根据它们在mother 中被选中的概率,随机抽取p1s 中的50 个进行替换(将这50 个称为p2)。例如,-4 比-6 更可能被选中,后者更靠近尾部区域。
我想知道下面的 R 代码是否正确捕获了我上面描述的内容?
mother <- rnorm(1e6)
p1 <- mother[mother <= -4]
p2 <- sample(p1, 50, replace = T) # How can I define probability of being selected here?
【问题讨论】:
标签: r random sampling resampling