lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 5f1c14f1 2/5: Augment unit test of IRC 7702 t


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 5f1c14f1 2/5: Augment unit test of IRC 7702 tables
Date: Thu, 27 Jan 2022 15:26:07 -0500 (EST)

branch: master
commit 5f1c14f1f03d0c641d4f423ce6070a68f4df1a6f
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Augment unit test of IRC 7702 tables
    
    These new tests validate lmi's calculations against those in this
    spreadsheet:
      https://download.savannah.gnu.org/releases/lmi/OLCF_CSO.xls
---
 irc7702_tables.hpp      |   3 +
 irc7702_tables_test.cpp | 532 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 535 insertions(+)

diff --git a/irc7702_tables.hpp b/irc7702_tables.hpp
index 81e8d470..e2fb79af 100644
--- a/irc7702_tables.hpp
+++ b/irc7702_tables.hpp
@@ -33,6 +33,9 @@
 class LMI_SO irc7702_tables final
 {
     friend void Test_Corridor_and_7PP();
+    friend void Test_1980_CSO();
+    friend void Test_2001_CSO();
+    friend void Test_2017_CSO();
 
   public:
     irc7702_tables
diff --git a/irc7702_tables_test.cpp b/irc7702_tables_test.cpp
index 92afa21b..4b7a9d35 100644
--- a/irc7702_tables_test.cpp
+++ b/irc7702_tables_test.cpp
@@ -23,6 +23,7 @@
 
 #include "irc7702_tables.hpp"
 
+#include "commutation_functions.hpp"
 #include "et_vector.hpp"
 #include "materially_equal.hpp"
 #include "math_functions.hpp"
@@ -591,11 +592,542 @@ void Test_Corridor_and_7PP()
             << '\t' << (ss_ol_7pp[j] - ol_7pp[j]) / ol_7pp[j]
             << '\n';
         }
+    std::cout << std::endl;
+}
+
+// These three arrays were imported from the 'OLCF_CSO' spreadsheet by
+// "exporting" from gnumeric as "raw" text. They show semicontinuous
+// NSPs, using OL rather than UL commutation functions.
+//
+// The qx, Dx, Cx, and Ax columns are validated against calculations
+// performed here. It is asserted that all match within the default
+// comparison tolerance. The initial Ax values, which are the most
+// sensitive because they depend on the entire Dx and Cx vectors, are
+// explicitly displayed along with their relative errors, which are on
+// the order of 5e-15 or so for architectures that use the x87, and
+// 5e-16 or so for architectures that, like gnumeric, don't (and whose
+// values are therefore slightly less accurate).
+//
+// The Nx and Mx columns are not compared, because they are defined
+// differently. The spreadsheet canonically calculates them as the
+// backward sums of the entire Dx and Cx vectors. Class OLCommFns,
+// OTOH, truncates them at the maturity age, because mortality beyond
+// deemed maturity is irrelevant. Thus, with the spreadsheet's
+// canonical Mx, the net single premium (written here as "Ax", though
+// the correct symbol is really "Ax:ω" with ω in an "angle") is
+//   Ax = ((Mx - Mω) * i/δ + Dω) / Dx
+// whereas class OLCommFns truncates C[100..ω], so its NSP formula is
+//   Ax = ( Mx       * i/δ + Dω) / Dx
+// and the unit tests demonstrate the equivalence of these methods.
+//
+// Of course, for 1980 CSO, ω=100, and if that coincides with the
+// maturity age, then Mω is zero anyway--as, incidentally, is Dω.
+//
+// Note well that it is not permissible to force q to unity at the
+// 7702 deemed endowment age, or to multiply the endowment benefit
+// (represented by Dω above) by i/δ.
+
+struct cf_data
+    {
+    double qx;
+    double Dx;
+    double Cx;
+    double Ax;
+    };
+
+static std::vector<cf_data> const olcf_1980_cso_endt_100 =
+{{0.00000, 1                     , 0                     , 
0.06996023573869656} // 0
+,{0.00000, 0.9615384615384615    , 0                     , 
0.07275864516824443} // 1
+,{0.00000, 0.9245562130177513    , 0                     , 
0.07566899097497422} // 2
+,{0.00000, 0.8889963586709146    , 0                     , 
0.07869575061397319} // 3
+,{0.00000, 0.8548041910297255    , 0                     , 
0.08184358063853213} // 4
+,{0.00000, 0.8219271067593513    , 0                     , 
0.08511732386407342} // 5
+,{0.00000, 0.7903145257301454    , 0                     , 
0.08852201681863638} // 6
+,{0.00000, 0.7599178132020628    , 0                     , 
0.09206289749138184} // 7
+,{0.00000, 0.7306902050019833    , 0                     , 
0.09574541339103712} // 8
+,{0.00000, 0.7025867355788301    , 0                     , 
0.09957522992667861} // 9
+,{0.00000, 0.6755641688257982    , 0                     , 
0.10355823912374576} // 10
+,{0.00000, 0.6495809315632675    , 0                     , 0.1077005686886956 
} // 11
+,{0.00000, 0.6245970495800648    , 0                     , 
0.11200859143624343} // 12
+,{0.00000, 0.6005740861346777    , 0                     , 
0.11648893509369317} // 13
+,{0.00000, 0.5774750828218054    , 0                     , 
0.12114849249744092} // 14
+,{0.00136, 0.5552645027132743    , 0.0007261151189327433 , 
0.12599443219733858} // 15
+,{0.00148, 0.5331820605669079    , 0.0007587590861913687 , 0.1298237475779462 
} // 16
+,{0.00157, 0.51191629915122      , 0.0007727967208340531 , 
0.13370517462339784} // 17
+,{0.00163, 0.49145441400149287   , 0.0007702602834831089 , 0.1376683261301615 
} // 18
+,{0.00167, 0.47178206087179847   , 0.0007575731169768302 , 0.1417437145237867 
} // 19
+,{0.00168, 0.45287902387513707   , 0.0007315738077982983 , 
0.14595402464894122} // 20
+,{0.00166, 0.4347290260721412    , 0.0006938944069997638 , 
0.15033136195334337} // 21
+,{0.00163, 0.41731478450852055   , 0.0006540606718739312 , 
0.15490878202535494} // 22
+,{0.00159, 0.4006101552017035    , 0.0006124712949718352 , 
0.15970306239181276} // 23
+,{0.00155, 0.3845896010143584    , 0.0005731864245887072 , 
0.16473151586215667} // 24
+,{0.00150, 0.3692245068584482    , 0.0005325353464304541 , 0.1700034845328251 
} // 25
+,{0.00147, 0.35449102894053897   , 0.0005010594351371079 , 
0.17553712570122826} // 26
+,{0.00145, 0.34035569916153496   , 0.0004745343882540631 , 0.1813259520553663 
} // 27
+,{0.00144, 0.3267905609593757    , 0.00045247923825144325, 
0.18737186890941998} // 28
+,{0.00144, 0.3137692139919175    , 0.00043444968091188574, 
0.19367702683904178} // 29
+,{0.00145, 0.30126671761900875   , 0.00042003532744957947, 
0.20024384730732278} // 30
+,{0.00148, 0.2892595008446742    , 0.00041163852043280555, 0.207075049583432  
} // 31
+,{0.00152, 0.2777224969071385    , 0.0004059021108642793 , 0.2141656101536879 
} // 32
+,{0.00158, 0.26663496029984585   , 0.0004050800358401504 , 
0.22151874176049685} // 33
+,{0.00165, 0.25597468948324237   , 0.00040611369004552874, 0.2291301235833054 
} // 34
+,{0.00173, 0.24572339542845675   , 0.0004087514173954136 , 0.237003600175319  
} // 35
+,{0.00182, 0.23586374418688988   , 0.00041276155232705723, 0.245143468549904  
} // 36
+,{0.00194, 0.2263793001658363    , 0.0004222844637708869 , 0.253554514441076  
} // 37
+,{0.00207, 0.2172501195418409    , 0.00043241129562654864, 0.2622268687648992 
} // 38
+,{0.00221, 0.208461934417682     , 0.0004429816106375742 , 
0.27116612801647216} // 39
+,{0.00238, 0.200001186098672     , 0.0004576950220334994 , 0.2803784985374118 
} // 40
+,{0.00256, 0.19185113776515114   , 0.0004722489544988336 , 
0.28985620739552376} // 41
+,{0.00275, 0.183999998896608     , 0.0004865384586208384 , 0.2996065832192247 
} // 42
+,{0.00296, 0.1764365374035022    , 0.0005021655295330447 , 
0.30963770976383115} // 43
+,{0.00319, 0.1691483512046037    , 0.000518830038791044  , 
0.31995146144805287} // 44
+,{0.00345, 0.16212381535025097   , 0.0005378145797676594 , 0.3305505933349382 
} // 45
+,{0.00373, 0.15535046941085826   , 0.0005571704335600974 , 0.341432008524383  
} // 46
+,{0.00403, 0.14881828092303437   , 0.0005766708385767581 , 
0.35260037589916077} // 47
+,{0.00436, 0.14251783004895627   , 0.0005974785952052397 , 
0.36406148557339424} // 48
+,{0.00472, 0.13643889645186807   , 0.0006192226838969396 , 
0.37581587219217266} // 49
+,{0.00513, 0.13057202390443773   , 0.000644071617913236  , 0.3878654490561384 
} // 50
+,{0.00560, 0.12490595136712306   , 0.0006725705073614318 , 
0.40020116967582187} // 51
+,{0.00614, 0.11942930580717996   , 0.0007050922477462355 , 0.4128096827876754 
} // 52
+,{0.00676, 0.11413077872069602   , 0.0007418500616845241 , 0.4256737093714063 
} // 53
+,{0.00745, 0.10899928332360011   , 0.0007808121738084815 , 
0.43877244321312925} // 54
+,{0.00822, 0.10402619102196084   , 0.0008222070098081904 , 0.4520934108082495 
} // 55
+,{0.00906, 0.09920297666515415   , 0.0008642105467175929 , 
0.46562122835766945} // 56
+,{0.00995, 0.09452326701593061   , 0.0009043331796235669 , 0.479348963536791  
} // 57
+,{0.01094, 0.08998342356646356   , 0.0009465563979010685 , 
0.49328339262182047} // 58
+,{0.01205, 0.08557596626216006   , 0.0009915292244798352 , 0.5074084065058735 
} // 59
+,{0.01329, 0.08129305371990482   , 0.0010388314268630144 , 0.5217018250832864 
} // 60
+,{0.01467, 0.07712756638073777   , 0.0010879436526975222 , 0.5361411514220666 
} // 61
+,{0.01626, 0.07307317786724264   , 0.001142471030885928  , 0.5507041451317363 
} // 62
+,{0.01806, 0.06912019999530891   , 0.001200298857610845  , 0.5653416925662889 
} // 63
+,{0.02006, 0.06526143190710926   , 0.0012587926192852035 , 0.5800115295184447 
} // 64
+,{0.02225, 0.061492584214473685  , 0.001315586537280807  , 0.59468274913801   
} // 65
+,{0.02462, 0.0578118982843285    , 0.0013685855151540072 , 0.6093356869327694 
} // 66
+,{0.02716, 0.05421977821977725   , 0.0014159703619703364 , 0.6239618743881926 
} // 67
+,{0.02992, 0.05071843177243086   , 0.001459130267914549  , 0.6385641010388011 
} // 68
+,{0.03298, 0.047308592590192045  , 0.0015002282534851284 , 0.6531339442030868 
} // 69
+,{0.03644, 0.043988803083237986  , 0.0015412999849549924 , 0.6676428755603874 
} // 70
+,{0.04039, 0.04075562605661998   , 0.001582807438872001  , 0.6820380199156878 
} // 71
+,{0.04495, 0.037605294538647215  , 0.0016253442206848    , 0.6962484978192078 
} // 72
+,{0.05011, 0.03453359283570675   , 0.0016639214778819858 , 0.7101778065562088 
} // 73
+,{0.05578, 0.03154145624875911   , 0.0016917138745728684 , 0.7237461914716019 
} // 74
+,{0.06184, 0.02863660944154166   , 0.0017027768537162848 , 0.7369127230745416 
} // 75
+,{0.06824, 0.02583242453238146   , 0.0016950044712401064 , 0.7496807756529756 
} // 76
+,{0.07493, 0.023143865271434375  , 0.0016674709853736322 , 0.762076208310363  
} // 77
+,{0.08195, 0.020586245621774805  , 0.0016221565660619664 , 0.7741473103856222 
} // 78
+,{0.08952, 0.018172310377952267  , 0.0015642165625329681 , 0.785942940273249  
} // 79
+,{0.09788, 0.01590915880088267   , 0.0014972965994523033 , 0.7974716205132951 
} // 80
+,{0.10725, 0.013799971478319495  , 0.0014231220587016978 , 0.8087013716768419 
} // 81
+,{0.11782, 0.011846081285836278  , 0.001342024324131952  , 0.8195670093412536 
} // 82
+,{0.12954, 0.010048438450710621  , 0.0012516103047163977 , 0.8299765270142435 
} // 83
+,{0.14218, 0.008410349744043814  , 0.001149791852507836  , 0.8398567690239427 
} // 84
+,{0.15545, 0.006937082901380447  , 0.00103689378559576   , 0.8491828440834719 
} // 85
+,{0.16918, 0.005633378234962362  , 0.0009163989709528196 , 0.8579852941708562 
} // 86
+,{0.18316, 0.004500310870357143  , 0.0007925739798217443 , 0.8663287152911144 
} // 87
+,{0.19733, 0.0035346480109062772 , 0.0006706654730693612 , 0.8743237461946147 
} // 88
+,{0.21189, 0.0027280345374174437 , 0.0005558108058974828 , 0.8821133136391973 
} // 89
+,{0.22705, 0.002067299326234674  , 0.0004513272230976757 , 0.8898475429372621 
} // 90
+,{0.24316, 0.0015364605905895108 , 0.0003592363050074475 , 0.8977037679498459 
} // 91
+,{0.26082, 0.0011181296474824666 , 0.0002804140140926701 , 0.9058988789548937 
} // 92
+,{0.28175, 0.000794710646948163  , 0.00021529781228619705, 0.9147062038027668 
} // 93
+,{0.30983, 0.0005488470405485751 , 0.00016350892170496635, 0.9243944111339899 
} // 94
+,{0.35186, 0.00036422861728404806, 0.00012322834738227417, 0.9351088751845157 
} // 95
+,{0.42099, 0.00022699147692931043, 9.188571333891382e-05 , 0.9468047484797842 
} // 96
+,{0.54100, 0.0001263753221700385 , 6.573947047499118e-05 , 0.959089092476356  
} // 97
+,{0.74515, 5.577526238081506e-05 , 3.996243919525417e-05 , 0.9710313341646125 
} // 98
+,{1.00000, 1.3667620786298768e-05, 1.3141943063748814e-05, 0.9806435265780128 
} // 99
+};
+
+static std::vector<cf_data> const olcf_2001_cso_endt_100 =
+{{0.00087, 1                     , 0.0008365384615384615 , 
0.06169349926325286} // 0
+,{0.00052, 0.9607019230769229    , 0.0004803509615384615 , 
0.06332904924377729} // 1
+,{0.00036, 0.9232714981508874    , 0.0003195939801291533 , 
0.06536586944646716} // 2
+,{0.00026, 0.8874414619341856    , 0.00022186036548354642, 
0.06763770086028474} // 3
+,{0.00021, 0.8530872376481563    , 0.00017225799990972383, 0.0700962679147673 
} // 4
+,{0.00020, 0.8201039320463943    , 0.0001577122946243066 , 
0.07270121333995475} // 5
+,{0.00021, 0.7884037608269086    , 0.00015919691324389496, 0.0754203720944436 
} // 6
+,{0.00022, 0.7579213423433988    , 0.0001603295147264882 , 
0.07823944471540697} // 7
+,{0.00022, 0.7286101919693108    , 0.0001541290790704311 , 
0.08116250701668587} // 8
+,{0.00023, 0.7004325939683437    , 0.00015490336212761445, 
0.08420316075383812} // 9
+,{0.00023, 0.6733379754535874    , 0.0001489112830330049 , 
0.08735680931857745} // 10
+,{0.00026, 0.6472914497300318    , 0.00016182286243250797, 
0.09063735835218409} // 11
+,{0.00032, 0.6222338018779826    , 0.00019145655442399465, 
0.09402213243111687} // 12
+,{0.00037, 0.5981102760205593    , 0.00021278923281500668, 
0.09748785567653286} // 13
+,{0.00044, 0.5748932454023381    , 0.00024322406536252765, 
0.10104740581471842} // 14
+,{0.00056, 0.5525387426676548    , 0.00029752086143642947, 
0.10468662168308564} // 15
+,{0.00067, 0.5309897317036162    , 0.0003420799233090604 , 0.1083636434008345 
} // 16
+,{0.00078, 0.5102249697917065    , 0.00038266872734377984, 
0.11208997701214647} // 17
+,{0.00084, 0.49021826376468164   , 0.000395945520733012  , 
0.11586845545913037} // 18
+,{0.00088, 0.4709677696376148    , 0.00039851118969336637, 
0.11974709104915832} // 19
+,{0.00089, 0.45245511346185924   , 0.0003871971644048603 , 
0.12374838831731971} // 20
+,{0.00090, 0.43466579654892135   , 0.0003761530931673357 , 
0.12790447518472628} // 21
+,{0.00092, 0.41757172820387234   , 0.00036939037494957935, 
0.13222177144553934} // 22
+,{0.00092, 0.4011418867441584    , 0.00035485628442752474, 
0.13669812485199492} // 23
+,{0.00094, 0.3853584963541863    , 0.00034830479478166834, 
0.14135781931361338} // 24
+,{0.00096, 0.3701887109303974    , 0.0003417126562434437 , 
0.14619087439650802} // 25
+,{0.00101, 0.3556089709306771    , 0.0003453510198461384 , 0.1512045912830646 
} // 26
+,{0.00106, 0.34158635179811264   , 0.00034815532010192246, 
0.15638065143201596} // 27
+,{0.00106, 0.32810025987039104   , 0.00033440988025251387, 0.1617262458862364 
} // 28
+,{0.00105, 0.31514660922589266   , 0.0003181768650838339 , 
0.16729156335514273} // 29
+,{0.00105, 0.30270740892904374   , 0.000305618057091823  , 
0.17309411197589994} // 30
+,{0.00105, 0.29075919822083485   , 0.00029355495974218906, 
0.17913510558477674} // 31
+,{0.00106, 0.2792825971756759    , 0.00028465341635213116, 
0.18542434263691346} // 32
+,{0.00108, 0.26825630540641315   , 0.0002785738556143521 , 
0.19196373647935847} // 33
+,{0.00112, 0.25766018134285984   , 0.00027748019529231057, 
0.19875548305117569} // 34
+,{0.00116, 0.24747269417284215   , 0.00027602723580817006, 
0.20579393800402912} // 35
+,{0.00123, 0.23767848639192463   , 0.00028110051755968007, 
0.21308983137812526} // 36
+,{0.00129, 0.2282559056285217    , 0.000283125113712301  , 
0.22063036077780834} // 37
+,{0.00139, 0.21919370722140466   , 0.0002929608202286081 , 
0.22843462451929358} // 38
+,{0.00148, 0.2104702192003528    , 0.0002995153119389636 , 0.23648310273084   
} // 39
+,{0.00158, 0.20207569545763102   , 0.0003069996142529394 , 
0.24479531739370747} // 40
+,{0.00171, 0.19399655371039226   , 0.0003189751027353565 , 0.2533760708385076 
} // 41
+,{0.00186, 0.18621617269571875   , 0.00033304046270580466, 0.2622155257734542 
} // 42
+,{0.00204, 0.17872097174471605   , 0.00035056805996078915, 0.2713118299703247 
} // 43
+,{0.00226, 0.1714965201561123    , 0.00037267513033924395, 
0.28065630873296504} // 44
+,{0.00249, 0.16452782501976873   , 0.00039391758105694624, 0.2902335844382451 
} // 45
+,{0.00273, 0.15780591416872064   , 0.00041424052469289164, 
0.30005057928176015} // 46
+,{0.00299, 0.15132221540676924   , 0.0004350513692944615 , 0.3101149732292863 
} // 47
+,{0.00316, 0.1450670788295221    , 0.00044078073952047095, 0.3204282434962646 
} // 48
+,{0.00337, 0.13904679505809692   , 0.00045056509552479483, 0.3310687636434827 
} // 49
+,{0.00362, 0.13324827630649147   , 0.0004638065002206722 , 0.3420271863753563 
} // 50
+,{0.00393, 0.12765953610217498   , 0.00048240574700148816, 
0.35329527598055926} // 51
+,{0.00433, 0.12226714819739752   , 0.0005090545689372415 , 
0.36485287258721977} // 52
+,{0.00478, 0.11705551100548345   , 0.0005380051371213566 , 
0.37666189958703433} // 53
+,{0.00533, 0.11201537082968964   , 0.0005740787755021593 , 0.3887114411599356 
} // 54
+,{0.00595, 0.10713300856073787   , 0.0006129244239772984 , 
0.40096111837072174} // 55
+,{0.00663, 0.10239958380750143   , 0.0006527973467728215 , 
0.41339101751731383} // 56
+,{0.00735, 0.09780834092967083   , 0.0006912416402241159 , 
0.42598923359226254} // 57
+,{0.00797, 0.09335524002292092   , 0.0007154242913294997 , 0.438757632417056  
} // 58
+,{0.00867, 0.08904922957686369   , 0.0007423623273378926 , 0.4517802683897045 
} // 59
+,{0.00949, 0.08488189688118487   , 0.0007745473090408119 , 
0.46504111907724366} // 60
+,{0.01048, 0.08084266123056003   , 0.0008146452785541048 , 
0.47850521901890863} // 61
+,{0.01167, 0.07691868282775359   , 0.0008631163736537348 , 0.492114558427102  
} // 62
+,{0.01298, 0.07309715557610932   , 0.0009123087301710567 , 0.5057999518488907 
} // 63
+,{0.01437, 0.06937341778531868   , 0.0009585538592067588 , 0.5195376454670264 
} // 64
+,{0.01583, 0.0657466555497535    , 0.0010007399589928823 , 0.5333275467565968 
} // 65
+,{0.01731, 0.062217198069616245  , 0.0010355574024856317 , 0.5471779449892819 
} // 66
+,{0.01881, 0.058788671510606905  , 0.001063283568379342  , 0.5611241854155279 
} // 67
+,{0.02044, 0.055464285191819604  , 0.0010900865281930699 , 0.5752050183020814 
} // 68
+,{0.02212, 0.05224095692547962   , 0.0011111249684534702 , 0.5894147282489893 
} // 69
+,{0.02410, 0.04912056438296924   , 0.0011382746169514985 , 0.6037875906846719 
} // 70
+,{0.02632, 0.04609303728974969   , 0.001166508405255973  , 0.6182603186411595 
} // 71
+,{0.02919, 0.04315371975796488   , 0.001211208730514418  , 0.6328031512021315 
} // 72
+,{0.03219, 0.040282752575221036  , 0.0012468286590349663 , 0.6472381756757473 
} // 73
+,{0.03536, 0.03748658727867757   , 0.0012745439674750373 , 0.6615948491722642 
} // 74
+,{0.03885, 0.034770251492791844  , 0.0012988694908605415 , 0.6758957391725041 
} // 75
+,{0.04264, 0.032134064636823924  , 0.0013174966501097807 , 0.6901208424195457 
} // 76
+,{0.04700, 0.029580642423759372  , 0.0013368174941506639 , 0.7042684575751125 
} // 77
+,{0.05202, 0.02710610791331027   , 0.0013558266669715386 , 0.7182637358856074 
} // 78
+,{0.05775, 0.02470773863428833   , 0.0013719922174328376 , 0.7320203865253909 
} // 79
+,{0.06396, 0.02238544877707517   , 0.001376705099790123  , 0.7454537031362496 
} // 80
+,{0.07120, 0.020147764878166767  , 0.0013793469801206477 , 0.7585584087254529 
} // 81
+,{0.07877, 0.017993503864270472  , 0.0013628349032582545 , 0.7711951477373196 
} // 82
+,{0.08675, 0.015938611120078737  , 0.0013294947256411829 , 0.7834176605567776 
} // 83
+,{0.09553, 0.013996092889819138  , 0.0012856218786196367 , 0.7952704166560969 
} // 84
+,{0.10530, 0.012172159746206458  , 0.0012324311743034035 , 0.8067189870140341 
} // 85
+,{0.11564, 0.010471568581664344  , 0.001164357875753524  , 0.817699242888101  
} // 86
+,{0.12752, 0.008904458068154498  , 0.0010918235508183285 , 0.8282481461097343 
} // 87
+,{0.14004, 0.007470155360868689  , 0.0010058851507077414 , 0.8382133033932311 
} // 88
+,{0.15312, 0.006176956542435229  , 0.0009094380632477713 , 0.8476200559194569 
} // 89
+,{0.16606, 0.0050299432275553325 , 0.0008031465118921525 , 0.8565115198080305 
} // 90
+,{0.17629, 0.004033337360757206  , 0.0006836894647383536 , 0.865065220538486  
} // 91
+,{0.18814, 0.003194519535989728  , 0.0005779008706741416 , 0.8739423779820207 
} // 92
+,{0.20191, 0.0024937525293159814 , 0.0004841476665328747 , 0.8831841316080343 
} // 93
+,{0.21764, 0.0019136913039632605 , 0.0004004767071101577 , 0.8928688406607459 
} // 94
+,{0.23598, 0.001439611085162208  , 0.0003266532921890171 , 0.9031893845259976 
} // 95
+,{0.25318, 0.0010575881358515673 , 0.0002574616963797114 , 0.9144370698791693 
} // 96
+,{0.27166, 0.0007594499727083341 , 0.00019837709575571734, 0.9276720648790258 
} // 97
+,{0.28127, 0.0005318632626176807 , 0.00014384344218891827, 0.9442310764571445 
} // 98
+,{0.29532, 0.0003675635410973132 , 0.00010437390861236395, 0.9671805693459418 
} // 99
+,{0.31354, 0.0002490525732119756 , 7.508456135084888e-05 , 0} // 100
+,{0.33082, 0.00016438906673758917, 5.229152986358582e-05 , 0} // 101
+,{0.35039, 0.00010577488046101915, 3.5636981119938936e-05, 0} // 102
+,{0.37252, 6.606963470796408e-05 , 2.3665634924433434e-05, 0} // 103
+,{0.39746, 3.9862859987070474e-05, 1.5234511856212528e-05, 0} // 104
+,{0.42509, 2.3095161208278312e-05, 9.439925075025987e-06 , 0} // 105
+,{0.45425, 1.2766960702164698e-05, 5.576338364382994e-06 , 0} // 106
+,{0.48483, 6.6995853876984445e-06, 3.1232307533825354e-06, 0} // 107
+,{0.51627, 3.3186782732505845e-06, 1.647436569356807e-06 , 0} // 108
+,{0.54938, 1.543600231845678e-06 , 8.154068224724792e-07 , 0} // 109
+,{0.58366, 6.688241696868263e-07 , 3.7535184123020475e-07, 0} // 110
+,{0.61739, 2.6774832193020507e-07, 1.5894724661200893e-07, 0} // 111
+,{0.65079, 9.850306293626513e-08 , 6.163923877720383e-08 , 0} // 112
+,{0.68237, 3.3075244815358794e-08, 2.1701495004477286e-08, 0} // 113
+,{0.72403, 1.010162501029078e-08 , 7.032576496346954e-09 , 0} // 114
+,{0.76393, 2.6805244750864875e-09, 1.9689740983200195e-09, 0} // 115
+,{0.80553, 6.084532815708336e-10 , 4.712763191382245e-10 , 0} // 116
+,{0.85080, 1.137749131414231e-10 , 9.307663086607959e-11 , 0} // 117
+,{0.89394, 1.6322324077596468e-11, 1.4029979217237101e-11, 0} // 118
+,{0.93806, 1.6645631650671925e-12, 1.50140396406051e-12  , 0} // 119
+,{1.00000, 9.913754081179045e-14 , 9.532455847287543e-14 , 0} // 120
+};
+
+static std::vector<cf_data> const olcf_2017_cso_endt_95 =
+{{0.00028, 1                     , 0.0002745098039215686 , 
0.21741815287711275} // 0
+,{0.00016, 0.9801176470588235    , 0.0001537439446366782 , 
0.22154575798805737} // 1
+,{0.00014, 0.9607459100346021    , 0.0001318670856910238 , 
0.22585121462282423} // 2
+,{0.00012, 0.9417758878501933    , 0.00011079716327649331, 
0.23025907980703658} // 3
+,{0.00011, 0.9231988968075012    , 9.956066534198542e-05 , 
0.23477123791222634} // 4
+,{0.00010, 0.9049973969890709    , 8.872523499892852e-05 , 0.2393818983097429 
} // 5
+,{0.00010, 0.8871636247542862    , 8.697682595630258e-05 , 0.2440929488712412 
} // 6
+,{0.00010, 0.8696812827370693    , 8.526287085657542e-05 , 0.2488987010191843 
} // 7
+,{0.00009, 0.8525434456948976    , 7.522442167896155e-05 , 0.2538010584458289 
} // 8
+,{0.00009, 0.8357516831223383    , 7.374279556961808e-05 , 
0.25880947543790955} // 9
+,{0.00009, 0.8192906524224091    , 7.22903516843302e-05  , 0.263918520583895  
} // 10
+,{0.00010, 0.8031538394742068    , 7.874057249747126e-05 , 
0.26913021568535933} // 11
+,{0.00012, 0.7873269844022152    , 9.262670404731942e-05 , 0.2744392672262054 
} // 12
+,{0.00016, 0.7717965736902812    , 0.00012106612920631861, 
0.27984043738371517} // 13
+,{0.00023, 0.756542241410285     , 0.00017059285835722114, 
0.28532130282050683} // 14
+,{0.00035, 0.7415374869556477    , 0.0002544491376808595 , 
0.29086233480487966} // 15
+,{0.00050, 0.7267430870933462    , 0.00035624661132026774, 0.2964298434976585 
} // 16
+,{0.00069, 0.7121369760292152    , 0.0004817397190785867 , 0.3020044590992429 
} // 17
+,{0.00083, 0.6976917661919168    , 0.0005677295744502852 , 0.30755988737639   
} // 18
+,{0.00086, 0.6834438059078211    , 0.0005762369343928687 , 
0.31313271266888837} // 19
+,{0.00090, 0.6694667100340592    , 0.0005907059206182875 , 0.3188009641350025 
} // 20
+,{0.00093, 0.655749205877479     , 0.0005978889818294661 , 
0.32456011722695355} // 21
+,{0.00096, 0.6422934893294243    , 0.0006045115193688699 , 0.3304193402517986 
} // 22
+,{0.00099, 0.629094987823204     , 0.000610592194063698  , 0.3363810845820299 
} // 23
+,{0.00102, 0.6161491997894696    , 0.0006161491997894696 , 
0.34244786233150026} // 24
+,{0.00105, 0.603451693731063     , 0.0006212002729584472 , 
0.34862224793527063} // 25
+,{0.00105, 0.5909981073065151    , 0.0006083804045802362 , 0.354906879772108  
} // 26
+,{0.00103, 0.5788015287194542    , 0.0005844760535108214 , 0.3613239421611907 
} // 27
+,{0.00101, 0.566868003083209     , 0.0005613104736412166 , 
0.36788908075187693} // 28
+,{0.00100, 0.5551916337255832    , 0.0005443055232603757 , 
0.37460514689948776} // 29
+,{0.00100, 0.5437612177371154    , 0.0005330992330756033 , 0.3814687515932338 
} // 30
+,{0.00104, 0.5325661338425277    , 0.0005430086070551263 , 0.3884766362655272 
} // 31
+,{0.00111, 0.521580652022874     , 0.0005676024742601864 , 
0.39560723483940036} // 32
+,{0.00119, 0.510785977940322     , 0.0005959169742637089 , 0.4028454746476685 
} // 33
+,{0.00128, 0.5001746496338951    , 0.0006276701485601822 , 
0.41018864790658477} // 34
+,{0.00137, 0.489739633414082     , 0.0006577875468404828 , 0.4176342349307567 
} // 35
+,{0.00150, 0.4794791079571615    , 0.0007051163352311198 , 
0.42518576934908353} // 36
+,{0.00162, 0.4693724404855154    , 0.0007454738760652304 , 
0.43282376989715565} // 37
+,{0.00176, 0.4594235854234597    , 0.0007927308924953815 , 0.4405578024017338 
} // 38
+,{0.00190, 0.4496225489344259    , 0.0008375321989954991 , 0.4483805663338432 
} // 39
+,{0.00206, 0.4399688883249514    , 0.0008885646175974509 , 
0.45629620315442343} // 40
+,{0.00221, 0.43045348275980594   , 0.0009326492126462462 , 
0.46429804918741396} // 41
+,{0.00234, 0.4210805691793203    , 0.0009660083645878524 , 
0.47239597822223395} // 42
+,{0.00240, 0.41185807906611827   , 0.0009690778330967486 , 0.4806051911637435 
} // 43
+,{0.00247, 0.40281335262388196   , 0.0009754401774323417 , 0.4889668947443964 
} // 44
+,{0.00254, 0.39393961141460876   , 0.0009809868754834376 , 0.4974803907246572 
} // 45
+,{0.00261, 0.3852343184329565    , 0.0009857466383431533 , 0.5061503041422459 
} // 46
+,{0.00267, 0.3766949577076926    , 0.0009860544481171954 , 0.5149813978142519 
} // 47
+,{0.00274, 0.36832272761824814   , 0.0009894159545823528 , 0.5239834497023577 
} // 48
+,{0.00281, 0.36011129739664133   , 0.0009920713192985904 , 0.5331566583717504 
} // 49
+,{0.00293, 0.352058220246036     , 0.001011304495412633  , 0.5425062267781304 
} // 50
+,{0.00309, 0.34414381339285793   , 0.0010425533170430696 , 0.5520145506492935 
} // 51
+,{0.00328, 0.336353342166151     , 0.0010816068257891913 , 0.5616696027175405 
} // 52
+,{0.00350, 0.3286765717684764    , 0.001127811765872223  , 0.5714647072653769 
} // 53
+,{0.00375, 0.3211041213404772    , 0.0011805298578694016 , 0.5813939959109437 
} // 54
+,{0.00405, 0.31362743224063766   , 0.001245285392720179  , 0.5914524462682803 
} // 55
+,{0.00439, 0.30623258935300307   , 0.0013180010463330228 , 0.6016277211310874 
} // 56
+,{0.00478, 0.29891002773112096   , 0.0014007744436811355 , 0.6119128177117398 
} // 57
+,{0.00522, 0.29164827235153545   , 0.0014925529232107991 , 0.6222980163439987 
} // 58
+,{0.00574, 0.28443712585280434   , 0.0016006559827402911 , 0.6327750346333966 
} // 59
+,{0.00633, 0.27725927132393063   , 0.0017206384190985105 , 0.6433260161023885 
} // 60
+,{0.00702, 0.2701021766043629    , 0.0018589385095712035 , 0.6539388784413224 
} // 61
+,{0.00779, 0.26294711698490225   , 0.0020081941581494007 , 0.6645931314823803 
} // 62
+,{0.00866, 0.2557830970035195    , 0.0021716486471083122 , 0.6752777650038385 
} // 63
+,{0.00962, 0.2485960935132049    , 0.002344602372153952  , 0.6859775718925574 
} // 64
+,{0.01064, 0.2413770579349097    , 0.0025178940161053325 , 0.6966833345084288 
} // 65
+,{0.01173, 0.23412628042988456   , 0.0026924522249436728 , 0.7073976635025602 
} // 66
+,{0.01288, 0.22684311682396271   , 0.002864450337933961  , 0.7181222782351432 
} // 67
+,{0.01413, 0.2195307622345785    , 0.003041146735661367  , 0.7288641187428753 
} // 68
+,{0.01553, 0.2121850907492195    , 0.0032306220189562535 , 0.7396214181043725 
} // 69
+,{0.01716, 0.20479397675478833   , 0.0034453574912864395 , 0.7503824992342208 
} // 70
+,{0.01909, 0.1973330510918394    , 0.0036932234758266804 , 0.7611199336314602 
} // 71
+,{0.02134, 0.189770552104408     , 0.003970297629321634  , 0.7717956411429833 
} // 72
+,{0.02394, 0.18207926325735285   , 0.004273507414099047  , 0.7823747351221916 
} // 73
+,{0.02686, 0.1742355742107567    , 0.004588203454216592  , 0.7928238222489402 
} // 74
+,{0.03006, 0.16623098694848604   , 0.004898924968305383  , 0.8031245095112116 
} // 75
+,{0.03351, 0.15807263086354367   , 0.005193150843369949  , 0.8132744208987969 
} // 76
+,{0.03722, 0.14978001666990814   , 0.0054655021769156676 , 0.8232841677474979 
} // 77
+,{0.04125, 0.1413776514210335    , 0.005717478550115326  , 0.833169446309021  
} // 78
+,{0.04577, 0.13288806205874104   , 0.005963026078851547  , 0.8429430995117917 
} // 79
+,{0.05091, 0.12431938770422792   , 0.006205000027472787  , 0.852599239284631  
} // 80
+,{0.05683, 0.11567675262373103   , 0.006445009658437877  , 0.8621245659655759 
} // 81
+,{0.06333, 0.10696357134521998   , 0.006641179385581158  , 0.8714978560720527 
} // 82
+,{0.07139, 0.09822506703130117   , 0.006874791701337833  , 0.8807441290391964 
} // 83
+,{0.08063, 0.08942429362346724   , 0.007068902740058983  , 0.8897787744986437 
} // 84
+,{0.09127, 0.08060197336137949   , 0.0072122961849932395 , 0.8985943756205763 
} // 85
+,{0.10347, 0.07180924632616313   , 0.007284414428792253  , 0.9071853855633201 
} // 86
+,{0.11724, 0.06311680745960298   , 0.007254720104474365  , 0.915560893908006  
} // 87
+,{0.13258, 0.054624502895136394  , 0.007100114307683513  , 0.9237658946874017 
} // 88
+,{0.14894, 0.04645331990323452   , 0.006783095555282106  , 0.9318897284742068 
} // 89
+,{0.16612, 0.03875937493808507   , 0.006312458200700678  , 0.9401253010172567 
} // 90
+,{0.18355, 0.03168692899350036   , 0.005702093937997051  , 0.9487601209876477 
} // 91
+,{0.20075, 0.025363522722297423  , 0.004991889398530596  , 0.9582410206645128 
} // 92
+,{0.21762, 0.01987430934881982   , 0.0042402423534217346 , 0.9692273589784797 
} // 93
+,{0.23331, 0.015244374655225146  , 0.003486926520402528  , 0.9826719605869627 
} // 94
+,{0.24714, 0.011458538827857419  , 0.002776336554820277  , 0} // 95
+,{0.26511, 0.008457525041118368  , 0.0021982102584812654 , 0} // 96
+,{0.28442, 0.006093480958301449  , 0.0016991253472157825 , 0} // 97
+,{0.30563, 0.004274875592295442  , 0.0012809119875227999 , 0} // 98
+,{0.32833, 0.002910142514727633  , 0.0009367520508436508 , 0} // 99
+,{0.35209, 0.0019163288459481459 , 0.0006614904150685124 , 0} // 100
+,{0.37447, 0.0012172633554688856 , 0.00044689079286513094, 0} // 101
+,{0.39680, 0.000746504653672992  , 0.0002904049476249443 , 0} // 102
+,{0.41866, 0.00044146235989759675, 0.00018119865842620379, 0} // 103
+,{0.43965, 0.0002516075767675185 , 0.00010845026580964657, 0} // 104
+,{0.45936, 0.00013822382906046962, 6.224950795805618e-05 , 0} // 105
+,{0.47743, 7.326404994436499e-05 , 3.4292603298959e-05   , 0} // 106
+,{0.50332, 3.7534896646496875e-05, 1.8521631549132165e-05, 0} // 107
+,{0.53061, 1.8277286731747125e-05, 9.507952071306218e-06 , 0} // 108
+,{0.55939, 8.410956489230178e-06 , 4.612749951480852e-06 , 0} // 109
+,{0.58972, 3.633285822274225e-06 , 2.1006091324623097e-06, 0} // 110
+,{0.62170, 1.4614357913359496e-06, 8.90759442621137e-07  , 0} // 111
+,{0.65542, 5.420207449631271e-07 , 3.4828552614091444e-07, 0} // 112
+,{0.69096, 1.8310736107783758e-07, 1.2403908059837514e-07, 0} // 113
+,{0.72843, 5.547794006617149e-08 , 3.9619407727844406e-08, 0} // 114
+,{0.76794, 1.4770729591931563e-08, 1.11206216498313e-08  , 0} // 115
+,{0.80958, 3.3604857932388603e-09, 2.667237341657173e-09 , 0} // 116
+,{0.85348, 6.273565732828858e-10 , 5.249375374171347e-10 , 0} // 117
+,{0.89977, 9.011792658569451e-11 , 7.949549686667681e-11 , 0} // 118
+,{0.94856, 8.85541155067075e-12  , 8.235185471082593e-12 , 0} // 119
+,{1.00000, 4.4659055898676834e-13, 4.378338813595768e-13 , 0} // 120
+};
+
+// These three tests serve as extra validation of calculations using
+// OL commutation functions. They match the 'OLCF_CSO' spreadsheet's
+// values very closely.
+
+void Test_1980_CSO()
+{
+    int constexpr endt_age = 100;
+    double constexpr iglp = 0.04;
+    std::vector<double> const operative_i(endt_age, iglp);
+    irc7702_tables z
+        (mce_1980cso
+        ,oe_orthodox
+        ,oe_age_last_birthday
+        ,mce_male
+        ,mce_nonsmoker
+        ,operative_i
+        ,1.0 / 12.0
+        ,0
+        ,endt_age
+        );
+
+    std::vector<double> i_over_delta(z.length_);
+    i_over_delta += z.i_ / log(1 + z.i_); // PETE's log(), not std::log()
+    OLCommFns const olcf(z.q_, z.i_);
+
+    std::vector<double> ol_nsp {};
+    ol_nsp <<= (olcf.M() * i_over_delta + olcf.Domega()) / olcf.D();
+
+    for(int j = 0; j < z.length_; ++j)
+        {
+        LMI_TEST(materially_equal(olcf_1980_cso_endt_100[j].qx, z.q_     [j]));
+        LMI_TEST(materially_equal(olcf_1980_cso_endt_100[j].Dx, olcf.D ()[j]));
+        LMI_TEST(materially_equal(olcf_1980_cso_endt_100[j].Cx, olcf.C ()[j]));
+        LMI_TEST(materially_equal(olcf_1980_cso_endt_100[j].Ax, ol_nsp   [j]));
+        }
+
+    double const observed = ol_nsp[0];
+    double const expected = olcf_1980_cso_endt_100[0].Ax;
+    std::cout.precision(21);
+    std::cout
+        << "Initial Ax (the most sensitive value) for 1980 CSO:"
+        << "\n  spreadsheet:    " << expected
+        << "\n  C++ OLCommFns:  " << observed
+        << "\n  relative error: " << (observed - expected) / expected
+        << std::endl
+        ;
+}
+
+void Test_2001_CSO()
+{
+    int constexpr endt_age = 100;
+    double constexpr iglp = 0.04;
+    std::vector<double> const operative_i(endt_age, iglp);
+    irc7702_tables z
+        (mce_2001cso
+        ,oe_orthodox
+        ,oe_age_nearest_birthday_ties_younger
+        ,mce_unisex
+        ,mce_unismoke
+        ,operative_i
+        ,1.0 / 12.0
+        ,0
+        ,endt_age
+        );
+
+    std::vector<double> i_over_delta(z.length_);
+    i_over_delta += z.i_ / log(1 + z.i_); // PETE's log(), not std::log()
+    OLCommFns const olcf(z.q_, z.i_);
+
+    std::vector<double> ol_nsp {};
+    ol_nsp <<= (olcf.M() * i_over_delta + olcf.Domega()) / olcf.D();
+
+    for(int j = 0; j < z.length_; ++j)
+        {
+        LMI_TEST(materially_equal(olcf_2001_cso_endt_100[j].qx, z.q_     [j]));
+        LMI_TEST(materially_equal(olcf_2001_cso_endt_100[j].Dx, olcf.D ()[j]));
+        LMI_TEST(materially_equal(olcf_2001_cso_endt_100[j].Cx, olcf.C ()[j]));
+        LMI_TEST(materially_equal(olcf_2001_cso_endt_100[j].Ax, ol_nsp   [j]));
+        }
+
+    double const observed = ol_nsp[0];
+    double const expected = olcf_2001_cso_endt_100[0].Ax;
+    std::cout.precision(21);
+    std::cout
+        << "Initial Ax (the most sensitive value) for 2001 CSO:"
+        << "\n  spreadsheet:    " << expected
+        << "\n  C++ OLCommFns:  " << observed
+        << "\n  relative error: " << (observed - expected) / expected
+        << std::endl
+        ;
+}
+
+void Test_2017_CSO()
+{
+    int constexpr endt_age = 95;
+    double constexpr iglp = 0.02;
+    std::vector<double> const operative_i(endt_age, iglp);
+    irc7702_tables z
+        (mce_2017cso
+        ,oe_orthodox
+        ,oe_age_nearest_birthday_ties_younger
+        ,mce_male
+        ,mce_unismoke
+        ,operative_i
+        ,1.0 / 12.0
+        ,0
+        ,endt_age
+        );
+
+    std::vector<double> i_over_delta(z.length_);
+    i_over_delta += z.i_ / log(1 + z.i_); // PETE's log(), not std::log()
+    OLCommFns const olcf(z.q_, z.i_);
+
+    std::vector<double> ol_nsp {};
+    ol_nsp <<= (olcf.M() * i_over_delta + olcf.Domega()) / olcf.D();
+
+    for(int j = 0; j < z.length_; ++j)
+        {
+        LMI_TEST(materially_equal(olcf_2017_cso_endt_95[j].qx, z.q_     [j]));
+        LMI_TEST(materially_equal(olcf_2017_cso_endt_95[j].Dx, olcf.D ()[j]));
+        LMI_TEST(materially_equal(olcf_2017_cso_endt_95[j].Cx, olcf.C ()[j]));
+        LMI_TEST(materially_equal(olcf_2017_cso_endt_95[j].Ax, ol_nsp   [j]));
+        }
+
+    double const observed = ol_nsp[0];
+    double const expected = olcf_2017_cso_endt_95[0].Ax;
+    std::cout.precision(21);
+    std::cout
+        << "Initial Ax (the most sensitive value) for 2017 CSO:"
+        << "\n  spreadsheet:    " << expected
+        << "\n  C++ OLCommFns:  " << observed
+        << "\n  relative error: " << (observed - expected) / expected
+        << std::endl
+        ;
 }
 
 int test_main(int, char*[])
 {
     Test_Corridor_and_7PP();
+    Test_1980_CSO();
+    Test_2001_CSO();
+    Test_2017_CSO();
 
     return EXIT_SUCCESS;
 }



reply via email to

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