[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master f135b80 09/10: Assert correspondence between
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master f135b80 09/10: Assert correspondence between DB_GuarInt and DB_NaarDiscount |
Date: |
Mon, 1 Mar 2021 09:39:24 -0500 (EST) |
branch: master
commit f135b80e7b431350fb596d9d061167fd0eeb0f82
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Assert correspondence between DB_GuarInt and DB_NaarDiscount
---
i7702.cpp | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/i7702.cpp b/i7702.cpp
index 6860d1d..465316b 100644
--- a/i7702.cpp
+++ b/i7702.cpp
@@ -26,7 +26,7 @@
#include "database.hpp"
#include "et_vector.hpp"
#include "math_functions.hpp"
-#include "miscellany.hpp" // each_equal()
+#include "miscellany.hpp" // each_equal(), minmax
#include "stratified_charges.hpp"
i7702::i7702
@@ -116,7 +116,15 @@ i7702::i7702
// benefit is discounted for calculating mortality charges,
// as seen in his formula (1):
// [0V + P - Q(1/(1 + ig) - OV - P)] (1 + ic) = 1V
- // For 7702, that 'ig' should generally be 'gross_' above.
+ // where it is the monthly (i upper 12 over 12) equivalent of
+ // the annual 'guar_int' rate above. Specifying a discount based
+ // on any other rate is presumably an error.
+ //
+ // In lmi's product database, DB_GuarInt is i. DB_NaarDiscount is
+ // (i upper 12)/12, rounded iff the contract specifies a rounded
+ // numerical value. An exception is thrown if the absolute value
+ // of the quantization error exceeds a small (though arbitrary)
+ // tolerance.
//
// However, if the contract applies no such discount, then 'ig'
// must be zero for formula (1) to apply. As of 2021-02, lmi
@@ -125,9 +133,21 @@ i7702::i7702
// a special database flag. Instead, the discount is deemed
// to be absent iff the contractual discount according to the
// product database is uniformly zero.
+ //
+ // For 7702, 'ig' should generally equal Eckley's 'ic'.
std::vector<double> const zero(database_.length(), 0.0);
std::vector<double> contractual_naar_discount;
database_.query_into(DB_NaarDiscount, contractual_naar_discount);
- ig_ = (zero == contractual_naar_discount) ? zero : gross_;
+ bool const no_naar_discount = zero == contractual_naar_discount;
+
+ std::vector<double> diff(database_.length(), 0.0);
+ diff += fabs
+ ( contractual_naar_discount
+ - apply_unary(i_upper_12_over_12_from_i<double>(), guar_int)
+ );
+ minmax<double> const mm(diff);
+ constexpr double tolerance {0.0000001};
+ LMI_ASSERT(no_naar_discount || mm < tolerance);
+ ig_ = no_naar_discount ? zero : gross_;
}
- [lmi-commits] [lmi] master updated (e5b0ac2 -> 8ffc9d2), Greg Chicares, 2021/03/01
- [lmi-commits] [lmi] master e3c0e51 02/10: Improve PETE unit test, Greg Chicares, 2021/03/01
- [lmi-commits] [lmi] master 56f9792 06/10: Turn a member into a local variable, Greg Chicares, 2021/03/01
- [lmi-commits] [lmi] master c695cd7 01/10: Add PETE vector tests, Greg Chicares, 2021/03/01
- [lmi-commits] [lmi] master 4d37390 03/10: Mention lmi's improved unit test, Greg Chicares, 2021/03/01
- [lmi-commits] [lmi] master 53186b7 05/10: Reorder independent blocks, Greg Chicares, 2021/03/01
- [lmi-commits] [lmi] master aab3295 07/10: Rename a local variable, Greg Chicares, 2021/03/01
- [lmi-commits] [lmi] master 3ef5a8e 08/10: Draw attention to an improvement deferred, Greg Chicares, 2021/03/01
- [lmi-commits] [lmi] master ecd20b1 04/10: Improve Max() and Min() implementations, Greg Chicares, 2021/03/01
- [lmi-commits] [lmi] master 8ffc9d2 10/10: Calculate 7702 'ig' more carefully, Greg Chicares, 2021/03/01
- [lmi-commits] [lmi] master f135b80 09/10: Assert correspondence between DB_GuarInt and DB_NaarDiscount,
Greg Chicares <=