本文整理匯總了Python中numpy.rate方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.rate方法的具體用法?Python numpy.rate怎麽用?Python numpy.rate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.rate方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_pmt_decimal
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rate [as 別名]
def test_pmt_decimal(self):
res = np.pmt(Decimal('0.08') / Decimal('12'), 5 * 12, 15000)
tgt = Decimal('-304.1459143262052370338701494')
assert_equal(res, tgt)
# Test the edge case where rate == 0.0
res = np.pmt(Decimal('0'), Decimal('60'), Decimal('15000'))
tgt = -250
assert_equal(res, tgt)
# Test the case where we use broadcast and
# the arguments passed in are arrays.
res = np.pmt([[Decimal('0'), Decimal('0.8')], [Decimal('0.3'), Decimal('0.8')]],
[Decimal('12'), Decimal('3')], [Decimal('2000'), Decimal('20000')])
tgt = np.array([[Decimal('-166.6666666666666666666666667'), Decimal('-19311.25827814569536423841060')],
[Decimal('-626.9081401700757748402586600'), Decimal('-19311.25827814569536423841060')]])
# Cannot use the `assert_allclose` because it uses isfinite under the covers
# which does not support the Decimal type
# See issue: https://github.com/numpy/numpy/issues/9954
assert_equal(res[0][0], tgt[0][0])
assert_equal(res[0][1], tgt[0][1])
assert_equal(res[1][0], tgt[1][0])
assert_equal(res[1][1], tgt[1][1])
示例2: test_rate
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rate [as 別名]
def test_rate(self):
assert_almost_equal(
np.rate(10, 0, -3500, 10000),
0.1107, 4)
示例3: test_rate_decimal
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rate [as 別名]
def test_rate_decimal(self):
rate = np.rate(Decimal('10'), Decimal('0'), Decimal('-3500'), Decimal('10000'))
assert_equal(Decimal('0.1106908537142689284704528100'), rate)
示例4: test_pmt
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rate [as 別名]
def test_pmt(self):
res = np.pmt(0.08 / 12, 5 * 12, 15000)
tgt = -304.145914
assert_allclose(res, tgt)
# Test the edge case where rate == 0.0
res = np.pmt(0.0, 5 * 12, 15000)
tgt = -250.0
assert_allclose(res, tgt)
# Test the case where we use broadcast and
# the arguments passed in are arrays.
res = np.pmt([[0.0, 0.8], [0.3, 0.8]], [12, 3], [2000, 20000])
tgt = np.array([[-166.66667, -19311.258], [-626.90814, -19311.258]])
assert_allclose(res, tgt)
示例5: test_rate
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rate [as 別名]
def test_rate(self):
assert_almost_equal(np.rate(10, 0, -3500, 10000),
0.1107, 4)
示例6: test_pmt
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rate [as 別名]
def test_pmt(self):
res = np.pmt(0.08/12, 5*12, 15000)
tgt = -304.145914
assert_allclose(res, tgt)
# Test the edge case where rate == 0.0
res = np.pmt(0.0, 5*12, 15000)
tgt = -250.0
assert_allclose(res, tgt)
# Test the case where we use broadcast and
# the arguments passed in are arrays.
res = np.pmt([[0.0, 0.8],[0.3, 0.8]],[12, 3],[2000, 20000])
tgt = np.array([[-166.66667, -19311.258],[-626.90814, -19311.258]])
assert_allclose(res, tgt)
示例7: pvfv
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rate [as 別名]
def pvfv(pval=None, fval=None, nrate=None, nper=None, pyr=1, noprint=True):
"""Computes the missing argument (set to ``None``) in a model relating the
present value, the future value, the number of compoundig periods
and the nominal interest rate in a cashflow.
Args:
pval (float, list): Present value.
fval (float, list): Future value.
nrate (float, list): Nominal interest rate per year.
nper (int, list): Number of compounding periods.
pyr (int, list): number of periods per year.
noprint (bool): prints enhanced output
Returns:
The value of the parameter set to ``None`` in the function call.
**Details**
The ``pvfv`` function computes and returns the missing value (``fval``,
``pval``, ``nper``, ``nrate``) in a model relating these variables.
The time intervals between consecutive payments are
assumed to be equial. For internal computations, the effective interest rate per
period is calculated as ``nrate / pyr``.
This function is used to simplify the call to the ``tvmm`` function.
See the ``tvmm`` function for details.
"""
return tvmm(pval=pval, fval=fval, pmt=0, nrate=nrate, nper=nper, due=0, pyr=pyr, noprint=noprint)
示例8: pmtfv
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rate [as 別名]
def pmtfv(pmt=None, fval=None, nrate=None, nper=None, pyr=1, noprint=True):
"""Computes the missing argument (set to ``None``) in a model relating the
the future value, the periodic payment, the number of
compounding periods and the nominal interest rate in a cashflow.
Args:
pmt (float, list): Periodic payment.
fval (float, list): Future value.
nrate (float, list): Nominal rate per year.
nper (int, list): Number of compounding periods.
pyr (int, list): number of periods per year.
noprint (bool): prints enhanced output
Returns:
The value of the parameter set to None in the function call.
**Details**
The ``pmtfv`` function computes and returns the missing value (``pmt``, ``fval``,
``nper``, ``nrate``) in a model relating a finite sequence of payments
made at the beginning or at the end of each period, a future value,
and a nominal interest rate. The time intervals between consecutive payments are
assumed to be equial. For internal computations, the effective interest rate per
period is calculated as ``nrate / pyr``.
This function is used to simplify the call to the ``tvmm`` function.
See the ``tvmm`` function for details.
"""
return tvmm(pval=0, fval=fval, pmt=pmt, nrate=nrate, nper=nper, due=1, pyr=pyr, noprint=noprint)
示例9: pvpmt
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import rate [as 別名]
def pvpmt(pmt=None, pval=None, nrate=None, nper=None, pyr=1, noprint=True):
"""Computes the missing argument (set to ``None``) in a model relating the
present value, the periodic payment, the number of
compounding periods and the nominal interest rate in a cashflow.
Args:
pmt (float, list): Periodic payment.
pval (float, list): Present value.
nrate (float, list): Nominal interest rate per year.
nper (int, list): Number of compounding periods.
pyr (int, list): number of periods per year.
noprint (bool): prints enhanced output
Returns:
The value of the parameter set to None in the function call.
**Details**
The ``pvpmt`` function computes and returns the missing value (``pmt``,
``pval``, ``nper``, ``nrate``) in a model relating a finite sequence of payments
made at the beginning or at the end of each period, a present value,
and a nominal interest rate. The time intervals between consecutive payments are
assumed to be equial. For internal computations, the effective interest rate per
period is calculated as ``nrate / pyr``.
This function is used to simplify the call to the ``tvmm`` function.
See the ``tvmm`` function for details.
"""
return tvmm(pval=pval, fval=0, pmt=pmt, nrate=nrate, nper=nper, due=0, pyr=pyr, noprint=noprint)