我们从Python开源项目中,提取了以下24个代码示例,用于说明如何使用numpy.ipmt()。
def test_broadcast(self): assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]), [21.5449442, 20.76156441], 4) assert_almost_equal(np.ipmt(0.1/12, list(range(5)), 24, 2000), [-17.29165168, -16.66666667, -16.03647345, -15.40102862, -14.76028842], 4) assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000), [-74.998201, -75.62318601, -76.25337923, -76.88882405, -77.52956425], 4) assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000, 0, [0, 0, 1, 'end', 'begin']), [-74.998201, -75.62318601, -75.62318601, -76.88882405, -76.88882405], 4)
def test_ipmt(self): np.round(np.ipmt(0.1/12, 1, 24, 2000), 2) == 16.67
def _rbl(rate, per, pmt, pv, when): """ This function is here to simply have a different name for the 'fv' function to not interfere with the 'fv' keyword argument within the 'ipmt' function. It is the 'remaining balance on loan' which might be useful as it's own function, but is easily calculated with the 'fv' function. """ return fv(rate, (per - 1), pmt, pv, when)
def ppmt(rate, per, nper, pv, fv=0.0, when='end'): """ Compute the payment against loan principal. Parameters ---------- rate : array_like Rate of interest (per period) per : array_like, int Amount paid against the loan changes. The `per` is the period of interest. nper : array_like Number of compounding periods pv : array_like Present value fv : array_like, optional Future value when : {{'begin', 1}, {'end', 0}}, {string, int} When payments are due ('begin' (1) or 'end' (0)) See Also -------- pmt, pv, ipmt """ total = pmt(rate, nper, pv, fv, when) return total - ipmt(rate, per, nper, pv, fv, when)