def update(self, time, current_state, next_state): """ updates the discounted total cost and health utility :param time: simulation time :param current_state: current health state :param next_state: next health state """ # cost and utility (per unit of time) during the period since the last recording until now cost = self.params.annualStateCosts[ current_state.value] + self.params.annualTreatmentCost utility = self.params.annualStateUtilities[current_state.value] # discounted cost and utility (continuously compounded) discounted_cost = Econ.pv_continuous_payment( payment=cost, discount_rate=self.params.discountRate, discount_period=(self.tLastRecorded, time)) discounted_utility = Econ.pv_continuous_payment( payment=utility, discount_rate=self.params.discountRate, discount_period=(self.tLastRecorded, time)) # update total discounted cost and utility self.totalDiscountedCost += discounted_cost self.totalDiscountedUtility += discounted_utility # update the time since last recording to the current time self.tLastRecorded = time
Econ.pv_single_payment(payment=10, discount_rate=0.05, discount_period=20, discount_continuously=True)) print( Econ.pv_single_payment(payment=10, discount_rate=0.05 / 100, discount_period=20 * 100, discount_continuously=False)) print( '\nPresent value of a continuous payment of $10 over the period [10, 20] at discount rate 5%:' ) print( Econ.pv_continuous_payment(payment=10, discount_rate=0.05, discount_period=(10, 20))) print( '\nPresent value of a continuous payment of $10 over the period [10, 20] at discount rate 0%:' ) print( Econ.pv_continuous_payment(payment=10, discount_rate=0, discount_period=(10, 20))) print('\nEquivalent annual value of $50 over 10 years at discount rate 5%:') print( Econ.equivalent_annual_value(present_value=50, discount_rate=0.05, discount_period=10))