def test_Ax():
    i = 2
    g = 0
    method = 'udd'
    cf_grf95 = commutation_table.CommutationFunctions(i=i,
                                                      g=g,
                                                      mt=soa_GRF95.table_qx)
    cf_tv7377 = commutation_table.CommutationFunctions(i=i,
                                                       g=g,
                                                       mt=soa_TV7377.table_qx)
    ages = range(0, max(mt_TV7377.w, mt_GRF95.w) + 10)

    a_grf = [
        mortality_insurance.Ax(mt=mt_GRF95, x=x, i=i, g=g, method=method)
        for x in ages
    ]
    a_tv = [
        mortality_insurance.Ax(mt=mt_TV7377, x=x, i=i, g=g, method=method)
        for x in ages
    ]
    a_grf_2 = [cf_grf95.Ax(x=x) for x in ages]
    a_tv_2 = [cf_tv7377.Ax(x=x) for x in ages]

    assert a_grf == pytest.approx(a_grf_2, rel=1e-16)
    assert a_tv == pytest.approx(a_tv_2, rel=1e-16)
Exemple #2
0
def test_IAx_4():
    capital = 1000
    i = 2
    x = 45
    inc = capital * 2 / 100.
    method = 'udd'
    cf_grf95 = commutation_table.CommutationFunctions(i=i,
                                                      g=0,
                                                      mt=soa_GRF95.table_qx)
    cf_tv7377 = commutation_table.CommutationFunctions(i=i,
                                                       g=0,
                                                       mt=soa_TV7377.table_qx)

    a_grf_cost_inc = (mortality_insurance.IAx(mt=mt_GRF95, x=x, i=i, inc=1, method=method) - \
                      mortality_insurance.Ax(mt=mt_GRF95, x=x, i=i, g=0, method=method)) * inc
    a_grf_cost_capital = mortality_insurance.Ax(
        mt=mt_GRF95, x=x, i=i, g=0, method=method) * capital
    a_grf = a_grf_cost_capital + a_grf_cost_inc
    a_tv_cost_inc = (mortality_insurance.IAx(mt=mt_TV7377, x=x, i=i, inc=1, method=method) - \
                     mortality_insurance.Ax(mt=mt_TV7377, x=x, i=i, g=0, method=method)) * inc
    a_tv_cost_capital = mortality_insurance.Ax(
        mt=mt_TV7377, x=x, i=i, g=0, method=method) * capital
    a_tv = a_tv_cost_capital + a_tv_cost_inc
    a_grf_2_cost_capital = capital * cf_grf95.Ax(x=x)
    a_grf_2_cost_inc = (cf_grf95.IAx(x=x) - cf_grf95.Ax(x=x)) * inc
    a_grf_2 = a_grf_2_cost_capital + a_grf_2_cost_inc

    cf_tv_2 = capital * cf_tv7377.Ax(x=x) + (cf_tv7377.IAx(x=x) -
                                             cf_tv7377.Ax(x=x)) * inc

    assert a_grf == pytest.approx(a_grf_2, rel=1e-16)
    assert a_tv == pytest.approx(cf_tv_2, rel=1e-16)
Exemple #3
0
def test_Ax():
    i = 2
    g = 1.2
    x = 45
    method = 'udd'
    cf_grf95 = commutation_table.CommutationFunctions(i=i, g=g, mt=soa_GRF95.table_qx)
    cf_tv7377 = commutation_table.CommutationFunctions(i=i, g=g, mt=soa_TV7377.table_qx)

    a_grf = mortality_insurance.Ax(mt=mt_GRF95, x=x, i=i, g=g, method=method)
    a_tv = mortality_insurance.Ax(mt=mt_TV7377, x=x, i=i, g=g, method=method)
    a_grf_2 = cf_grf95.Ax(x=x)
    cf_tv_2 = cf_tv7377.Ax(x=x)

    assert a_grf == pytest.approx(a_grf_2, rel=1e-16)
    assert a_tv == pytest.approx(cf_tv_2, rel=1e-16)