[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1f2d652 05/14: Calculate and store partial-mo
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1f2d652 05/14: Calculate and store partial-mortality tpx along with lx |
Date: |
Sun, 6 Sep 2020 07:50:37 -0400 (EDT) |
branch: master
commit 1f2d65200ef813e20262d4c4d2171945c257b10e
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Calculate and store partial-mortality tpx along with lx
lx is simply tpx times a constant radix, so it's just silly to calculate
lx in one place and then divide it by the radix to get tpx in another,
especially when that other place is an output routine that shouldn't be
performing such calculations. And division is generally to be avoided
where multiplication can be used instead.
Alternatively, lx could have replaced tpx in the monthly trace, which is
the only place where tpx is currently used. But tpx seems preferable
there, and might someday be useful elsewhere.
---
account_value.hpp | 1 +
ihs_acctval.cpp | 12 +++++++-----
ihs_avdebug.cpp | 4 +---
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/account_value.hpp b/account_value.hpp
index 6681257..523cea0 100644
--- a/account_value.hpp
+++ b/account_value.hpp
@@ -584,6 +584,7 @@ class LMI_SO AccountValue final
double YearsTotalSepAcctLoad;
std::vector<double> partial_mortality_qx;
+ std::vector<double> partial_mortality_tpx;
std::vector<double> partial_mortality_lx;
// For experience rating.
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 3f9b4a4..0b7d76c 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -420,9 +420,10 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
// composite values are multiplied by the number of lives inforce.
// Of course, a contract is not normally in force after maturity.
- double inforce_lives = yare_input_.NumberOfIdenticalLives;
- partial_mortality_qx.resize( BasicValues::GetLength());
- partial_mortality_lx.resize(1 + BasicValues::GetLength(), inforce_lives);
+ double const inforce_lives = yare_input_.NumberOfIdenticalLives;
+ partial_mortality_qx .resize( BasicValues::GetLength());
+ partial_mortality_tpx.resize(1 + BasicValues::GetLength(), 1.0);
+ partial_mortality_lx .resize(1 + BasicValues::GetLength(), inforce_lives);
// TODO ?? 'InvariantValues().InforceLives' may be thought of as
// counting potential inforce lives: it does not reflect lapses.
// It should either reflect lapses or be renamed. Meanwhile,
@@ -434,8 +435,9 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
for(int j = 0; j < BasicValues::GetLength(); ++j)
{
partial_mortality_qx[j] = GetPartMortQ(j);
- inforce_lives *= 1.0 - partial_mortality_qx[j];
- partial_mortality_lx[1 + j] = inforce_lives;
+ double const px = 1.0 - partial_mortality_qx[j];
+ partial_mortality_tpx[1 + j] = px * partial_mortality_tpx[j];
+ partial_mortality_lx [1 + j] = px * partial_mortality_lx [j];
}
}
InvariantValues().InforceLives = partial_mortality_lx;
diff --git a/ihs_avdebug.cpp b/ihs_avdebug.cpp
index 9b0fe78..6e802c8 100644
--- a/ihs_avdebug.cpp
+++ b/ihs_avdebug.cpp
@@ -433,9 +433,7 @@ void AccountValue::DebugPrint()
LMI_ASSERT(0 != yare_input_.NumberOfIdenticalLives);
SetMonthlyDetail
(eInforceFactor
- ,ItLapsed
- ? 0.0
- : partial_mortality_lx[Year] / yare_input_.NumberOfIdenticalLives
+ ,ItLapsed ? 0.0 : partial_mortality_tpx[Year]
);
// TODO ?? Claims appear as zero because SetClaims() is called not
- [lmi-commits] [lmi] master b4eb422 02/14: Rename a variable, (continued)
- [lmi-commits] [lmi] master b4eb422 02/14: Rename a variable, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 14c2920 07/14: Factor out partial-mortality calculations, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 338d589 10/14: Call set_partial_mortality() OAOO, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 915e4ef 03/14: Avoid reading back from ledger in class AccountValue, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 540e3ca 04/14: Simplify, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 73d5f2b 06/14: Refactor for terseness, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 2bcf8d3 08/14: Move commentary outside function body, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 7b9b0cf 11/14: Resolve a marked defect [339], Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 3cbd888 12/14: Improve documentation, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 3ff6e18 13/14: Add and use trivial const accessors, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 1f2d652 05/14: Calculate and store partial-mortality tpx along with lx,
Greg Chicares <=
- [lmi-commits] [lmi] master a1d6c16 09/14: Improve documentation, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 59860e3 14/14: Move partial mortality into base class, Greg Chicares, 2020/09/06