lmi-commits
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]