在R中编写以下代码的更好方法是什么?
base_case = rep(100,10)
mid_case = rep(200,10)
high_case = rep(1000,10)
base_prob = 0.75
mid_prob = 0.2
high_prob = 0.05
ev_case = base_case * base_prob + mid_case * mid_prob + high_case * high_prob
答案 0 :(得分:0)
你只是想知道如何矩阵乘法?例如
cbind(base, mid, hi) %*% c(.75,.2,.05)