我正在用 numpy 和我自己的代码计算 NPV,结果不同。我一定在某个地方犯了错误。任何指针?
// Solution 1
r = .06
flows = {0:1200, 3:-450, 6:-450, 15:-450}
print sum([C/(1+r)**i for i,C in flows.iteritems()])
// => 317
// Solution using numpy's npv function
flows = zeros(16)
flows[0] = 1200
flows[3] = -450
flows[6] = -450
flows[15]= -450
print np.npv(r, flows)
// => 299