lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 8d3e8f1 5/5: Accommodate and test the 1980 CS


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 8d3e8f1 5/5: Accommodate and test the 1980 CSO Table F errata
Date: Mon, 11 Mar 2019 19:40:42 -0400 (EDT)

branch: master
commit 8d3e8f15c98ac79b4ecad67453eee9d4c090a5af
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Accommodate and test the 1980 CSO Table F errata
---
 Makefile.am              |  1 +
 actuarial_table_test.cpp | 32 ++++++++++++++++++++++++++++++++
 cso_tables.cpp           | 29 ++++++++++++++++++++++++++++-
 objects.make             |  1 +
 4 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 99bf499..5c77c0e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -554,6 +554,7 @@ test_actuarial_table_SOURCES = \
   $(common_test_objects) \
   actuarial_table.cpp \
   actuarial_table_test.cpp \
+  cso_tables.cpp \
   timer.cpp \
   xml_lmi.cpp
 test_actuarial_table_CXXFLAGS = $(AM_CXXFLAGS)
diff --git a/actuarial_table_test.cpp b/actuarial_table_test.cpp
index e4ae9f4..10b3f2c 100644
--- a/actuarial_table_test.cpp
+++ b/actuarial_table_test.cpp
@@ -24,7 +24,9 @@
 #include "actuarial_table.hpp"
 
 #include "assert_lmi.hpp"
+#include "cso_tables.hpp"
 #include "miscellany.hpp"
+#include "oecumenic_enumerations.hpp"
 #include "test_tools.hpp"
 #include "timer.hpp"
 
@@ -212,6 +214,25 @@ void assert_table_nondegeneracy(actuarial_table const& t)
     LMI_ASSERT(rates.at(       0) != rates.at(       1));
     LMI_ASSERT(rates.at(length-2) != rates.at(length-1));
 }
+
+void test_80cso_erratum
+    (int              table_number
+    ,oenum_autopisty  autopisty
+    ,oenum_alb_or_anb alb_or_anb
+    )
+{
+    std::vector<double> v0 = cso_table
+        (oe_1980cso
+        ,autopisty
+        ,alb_or_anb
+        ,mce_male
+        ,mce_nonsmoker
+        );
+    actuarial_table const a(qx_cso, table_number);
+    // No smoker-nonsmoker distinction below age 15.
+    std::vector<double> v1 = a.values(15, 85);
+    BOOST_TEST(v0 == v1);
+}
 } // Unnamed namespace.
 
 void mete()
@@ -605,6 +626,16 @@ void test_exotic_lookup_methods_with_attained_age_table()
         );
 }
 
+void test_1980cso_errata()
+{
+    test_80cso_erratum(43, oe_heterodox, oe_age_last_birthday);
+    test_80cso_erratum(57, oe_orthodox , oe_age_last_birthday);
+    test_80cso_erratum(44, oe_heterodox, oe_age_nearest_birthday_ties_younger);
+    test_80cso_erratum(58, oe_orthodox , oe_age_nearest_birthday_ties_younger);
+    test_80cso_erratum(44, oe_heterodox, oe_age_nearest_birthday_ties_older);
+    test_80cso_erratum(58, oe_orthodox , oe_age_nearest_birthday_ties_older);
+}
+
 int test_main(int, char*[])
 {
     test_precondition_failures();
@@ -613,6 +644,7 @@ int test_main(int, char*[])
     test_e_reenter_at_inforce_duration();
     test_e_reenter_upon_rate_reset();
     test_exotic_lookup_methods_with_attained_age_table();
+    test_1980cso_errata();
 
     assay_speed();
 
diff --git a/cso_tables.cpp b/cso_tables.cpp
index d15f3f4..1364599 100644
--- a/cso_tables.cpp
+++ b/cso_tables.cpp
@@ -937,7 +937,7 @@ static double const 
q2017[cso_n_alb_or_anb][cso_n_gender][cso_n_smoking][cso_ome
 
 std::vector<double> cso_table
     (oenum_cso_era    cso_era
-    ,oenum_autopisty//autopisty
+    ,oenum_autopisty  autopisty
     ,oenum_alb_or_anb alb_or_anb
     ,mcenum_gender    gender
     ,mcenum_smoking   smoking
@@ -963,11 +963,38 @@ std::vector<double> cso_table
         :(oe_2017cso == cso_era) ? cso_omega_2017
         :                          throw "invalid cso omega"
         );
+
     if(mce_unismoke != smoking)
         {
         LMI_ASSERT(each_equal(p, p + sns_age, 0.0));
         }
+
     std::vector<double> v(p + sns_age, p + omega);
+
+    if
+        (oe_heterodox    == autopisty
+        && oe_1980cso    == cso_era
+        && mce_nonsmoker == smoking
+        && mce_male      == gender
+        )
+        {
+        // Intrude the errors of 1980 CSO Table F (which was
+        // ratified by NAIC) into Table E (which is correct and
+        // was also ratified by NAIC).
+        if(is_anb)
+            {
+            LMI_ASSERT(0.03831 == v[56]);
+            v[56] =    0.03891;
+            }
+        else
+            {
+            LMI_ASSERT(0.03644 == v[55]);
+            v[55] =    0.03673;
+            LMI_ASSERT(0.04039 == v[56]);
+            v[56] =    0.04070;
+            }
+        }
+
     LMI_ASSERT(0 == std::count(v.begin(), v.end(), 0.0));
     LMI_ASSERT(1.0 == v.back());
     return v;
diff --git a/objects.make b/objects.make
index ff21f26..c542b78 100644
--- a/objects.make
+++ b/objects.make
@@ -501,6 +501,7 @@ actuarial_table_test$(EXEEXT): \
   $(xmlwrapp_objects) \
   actuarial_table.o \
   actuarial_table_test.o \
+  cso_tables.o \
   timer.o \
   xml_lmi.o \
 



reply via email to

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