我正在尝试修复我的代码。我不确定我做错了什么,但代码应该从向量x
检索所有值:
- 大于平均值 两个标准差
或
- 小于平均值的两个标准差。
set.seed(2)
x = rnorm(10000)
average = mean(x)
upper_bound = average + sd(average)
lower_bound = average - sd(average)
boolean_vector = x < lower_bound | x > upper_bound
y = x[boolean_vector]
不能取整数的标准差,所以
upper_bound = average + sd(average)
lower_bound = average - sd(average)
你会做
upper_bound = average + sd(x)
lower_bound = average - sd(x)
加上2个标准差的距离所以是
upper_bound = average + 2*sd(x)
lower_bound = average - 2*sd(x)