/// <summary>
        /// Discount factor
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public double GetDiscountFactors(DateTime date)
        {
            // Convert dates to contineous time in untis of years
            var t = Utilities.ConvertToDayCountFraction(SettleDate, date);

            var interpolation = new BulirschStoerRationalInterpolation(T.ToArray(), DiscountFactor.ToArray());

            return(interpolation.Interpolate(t));
        }
        /// <summary>
        /// Discount factors
        /// </summary>
        /// <param name="dates"></param>
        /// <returns></returns>
        public Vector <double> GetDiscountFactors(DateTime[] dates)
        {
            // Convert dates to contineous time in untis of years
            var t = Vector <double> .Build.DenseOfArray(Utilities.ConvertToDayCountFraction(SettleDate, dates));

            var interpolation = new BulirschStoerRationalInterpolation(T.ToArray(), DiscountFactor.ToArray());

            var result = Vector <double> .Build.Dense(t.Count);

            t.Map(p => interpolation.Interpolate(p), result);

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Use this if CDF values are retrieved externally. The Payout can occor at any given time over teh expected region.
        /// </summary>
        /// <param name="SurvivalCdf"></param>
        /// <param name="conditionalFundValueAtTime"></param>
        /// <param name="dateIncrementTypes"></param>
        /// <param name="term"></param>
        /// <returns></returns>
        public static double ReturnExpectedValue(IDictionary <int, double> SurvivalCdf,
                                                 IList <PolicyData> conditionalFundValueAtTime,
                                                 DateIncrementTypes dateIncrementTypes, IDictionary <int, double> yield, int expectanceOverPeriod)
        {
            var result = 0d;

            foreach (var point in conditionalFundValueAtTime)
            {
                for (int i = 1; i <= expectanceOverPeriod; i++)
                {
                    result += (SurvivalCdf[i]
                               * point.SurrenderValue * (double)DiscountFactor.discountFactor((decimal)yield[i], i));
                }
            }
            return(result);
        }