thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

The behavior of the npv function does not match the documentation (Trac #2196) #5986

Open numpy-gitbot opened 11 years ago

numpy-gitbot commented 11 years ago

Original ticket http://projects.scipy.org/numpy/ticket/2196 on 2012-08-04 by trac user npgraham1, assigned to unknown.

The documentation for the npv indicates that it returns the true net present value, as given by the formula shown on the npv function's page. This is the technically correct and universally accepted definition of net present value. However, the function itself appears to mimic the Excel NPV function, which simply calculates the present value of a series of cash flows, and is known to be incorrect (but persists for compatibility reasons).

Put differently, the documentation indicates that the summation is from 0 to n-1, but the function returns a summation of 1 to n.

Since the current behavior is widely understood, it is probably acceptable to change the documentation to match, with a brief explanation of how to correctly compute NPV using the npv function. Alternatively, the function could be (easily) altered to match the documentation (a brief note that this is different from several popular spreadsheet NPV functions might be useful). Either way, one ought to change in order to match the other; as someone who studies finance, I'd prefer the correct calculation, but either way is reasonable.

numpy-gitbot commented 11 years ago

trac user npgraham1 wrote on 2012-08-04

Also, strictly speaking, the summation shown in the documentation should be from 0 to M-1, or from 1 to M, depending on the desired behavior. What is shown is 0 to M, which can never be correct.