[Numpy-discussion] Behavior or finance.npv function

Ralf Gommers ralf.gommers at gmail.com
Tue May 28 17:10:43 EDT 2013


On Thu, May 23, 2013 at 3:12 AM, Guillaume VIRY <guillaume.viry at gmail.com>wrote:

> Good morning all
>
> I have been using the financial functions for a while now, and the npv
> function has always bothered me.
>
All of them have always bothered me:)

> Indeed neither the documentation nor the implementation seem to be
> correct, and actually are not congruent with each other either.
>
> As stated in the bug report https://github.com/numpy/numpy/issues/649 :
>
> the documentation states that the summation is from 0 to M (should be M-1,
> if the input data is of size M by the way) which is the correct definition,
> but the implementation computes a summation from 1 to M, which is known to
> be wrong, and a mimic of Excel's NPV behavior.
>
> So basically, we would have the following :
>
> RealNPV(data) = data[0] + CurrentNPV(data[1:])
>
> Both behaviors are fine to me, as long as the documentation is clear about
> it. Ideally the implementation should be corrected, but in any case there
> should be a documentation fix at least.
>
> I'd be glad to have your opinion about it.
>
Looks like the code needs to be be changed. The current sum starting at 1
is different from what I see on wikipedia and other definitions scattered
over the internet.

Unless someone complains, I think just considering this a bug and changing
the code is OK.

Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130528/21ae72af/attachment.html>


More information about the NumPy-Discussion mailing list