w3resource

NumPy Financial functions: pv() function

numpy.pv() function

The pv() function is used to compute the present value.

Syntax:

numpy.pv(rate, nper, pmt, fv=0.0, when='end')

Given:

  • a future value, fv
  • an interest rate compounded once per period, of which there are
  • nper total
  • a (fixed) payment, pmt, paid either
  • at the beginning (when = {'begin', 1}) or the end (when = {'end', 0}) of each period

Version: 1.15.0

Parameter:

Name Description Required /
Optional
rate Rate of interest (per period)
array_like
Required
nper Number of compounding periods
array_like
Required
pmt Payment
array_like
Required
fv Future value
array_like
Optional
when When payments are due ('begin' (1) or 'end' (0))
{{'begin', 1}, {'end', 0}}, {string, int}
Optional

Return value: the value now

Returns: out : ndarray, float

Present value of a series of payments or investments.

Notes:

The present value is computed by solving the equation:

fv + pv*(1+rate)**nper +
pmt*(1 + rate*when)/rate*((1 + rate)**nper - 1) = 0

or, when rate == 0:

fv + pv + pmt * nper = 0

for pv, which is then returned.

NumPy.pv() method Example-1:

What is the present value (e.g., the initial investment) of an investment that needs to total $33139.75 after 10 years of saving $200 every month?
Assume the interest rate is 5% (annually) compounded monthly.

>>> import numpy as np
>>> np.pv(0.06/12, 10*12, -200, 33139.75)

Output:

-200.0007100715939

NumPy.pv() method Example-2:

By convention, the negative sign represents cash flow out (i.e., money not available today).
Thus, to end up with $33139.75 in 10 years saving $200 a month at 6% annual interest,one's initial deposit should also be $200.

If any input is array_like, pv returns an array of equal shape. Let's compare different interest rates in the example above:

>>> import numpy as np
>>> x = np.array((0.06, 0.04, 0.03))/12
>>> np.pv(x, 10*12, -200, 33139.75)

Output:

array([ -200.00071007, -2474.98535444, -3847.37286647])

So, to end up with the same $33139.75 under the same $200 per month "savings plan," for annual interest rates of 4% and 3%, one would need initial investments of $2474.99 and $3847.37, respectively.

Python - NumPy Code Editor:

Previous: fv() function
Next: npv() function



Follow us on Facebook and Twitter for latest update.