def print_comparative_outcomes(simOutputs_mono, simOutputs_combo): """ prints average increase in survival time, discounted cost, and discounted utility under combination therapy compared to mono therapy :param simOutputs_mono: output of a cohort simulated under mono therapy :param simOutputs_combo: output of a cohort simulated under combination therapy """ # Antibiotics exposure time increase_exposure_time = simOutputs_combo.get_sumStat_survival_times().get_total() \ - simOutputs_mono.get_sumStat_survival_times().get_total() print("Increase in total antibiotics exposure time (day):", increase_exposure_time) #### Survival time #### increase_survival_time = Stat.DifferenceStatIndp( name='Increase in survival time', x=simOutputs_combo.get_survival_times(), y_ref=simOutputs_mono.get_survival_times()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_survival_time.get_mean(), interval=increase_survival_time.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average change in antibiotic exposure time (day) " "and {:.{prec}%} confidence interval:".format(1 - Settings.ALPHA, prec=0), estimate_CI) #### Discounted total cost #### increase_discounted_cost = Stat.DifferenceStatIndp( name='Increase in discounted total cost', x=simOutputs_combo.get_costs(), y_ref=simOutputs_mono.get_costs()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_discounted_cost.get_mean(), interval=increase_discounted_cost.get_t_CI(alpha=Settings.ALPHA), deci=0, form=F.FormatNumber.CURRENCY) print( "Average increase in discounted total cost " "and {:.{prec}%} confidence interval:".format(1 - Settings.ALPHA, prec=0), estimate_CI) #### Discounted total utility #### increase_discounted_utility = Stat.DifferenceStatIndp( name='Increase in discounted total utility', x=simOutputs_combo.get_utilities(), y_ref=simOutputs_mono.get_utilities()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_discounted_utility.get_mean(), interval=increase_discounted_utility.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average increase in discounted total utility " "and {:.{prec}%} confidence interval:".format(1 - Settings.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes(simOutputs_mono, simOutputs_combo): """ prints average increase in survival time, discounted cost, and discounted utility under combination therapy compared to mono therapy :param simOutputs_mono: output of a cohort simulated under mono therapy :param simOutputs_combo: output of a cohort simulated under combination therapy """ # increase in survival time under combination therapy with respect to mono therapy increase_survival_time = Stat.DifferenceStatIndp( name='Increase in survival time', x=simOutputs_combo.get_survival_times(), y_ref=simOutputs_mono.get_survival_times()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_survival_time.get_mean(), interval=increase_survival_time.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average increase in survival time " "and {:.{prec}%} confidence interval:".format(1 - Settings.ALPHA, prec=0), estimate_CI) # increase in discounted total cost under combination therapy with respect to mono therapy increase_discounted_cost = Stat.DifferenceStatIndp( name='Increase in discounted cost', x=simOutputs_combo.get_costs(), y_ref=simOutputs_mono.get_costs()) # estimate and CI estimate_CI_cost = F.format_estimate_interval( estimate=increase_discounted_cost.get_mean(), interval=increase_discounted_cost.get_t_CI(alpha=Settings.ALPHA), deci=0, form=F.FormatNumber.CURRENCY) print( "Average increase in discounted cost " "and {:.{prec}%} confidence interval:".format(1 - Settings.ALPHA, prec=0), estimate_CI_cost) # increase in discounted total utility under combination therapy with respect to mono therapy increase_discounted_utility = Stat.DifferenceStatIndp( name='Increase in discounted cost', x=simOutputs_combo.get_utilities(), y_ref=simOutputs_mono.get_utilities()) # estimate and CI estimate_CI_utility = F.format_estimate_interval( estimate=increase_discounted_utility.get_mean(), interval=increase_discounted_utility.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average increase in discounted utility " "and {:.{prec}%} confidence interval:".format(1 - Settings.ALPHA, prec=0), estimate_CI_utility)
def print_comparative_outcomes(simOutputs_ANNUAL, simOutputs_SEMI): """ prints average increase in infection time, discounted cost, and discounted utility under combination therapy compared to mono therapy :param simOutputs_mono: output of a cohort simulated under mono therapy :param simOutputs_combo: output of a cohort simulated under combination therapy """ decrease_infection_time = Stat.DifferenceStatIndp( name="decrease in infection time", x=simOutputs_SEMI.get_infection_durations(), y_ref=simOutputs_ANNUAL.get_infection_durations()) estimate_CI = F.format_estimate_interval( estimate=decrease_infection_time.get_mean(), interval=decrease_infection_time.get_t_CI(alpha=Settings.ALPHA), deci=2) estimate_CI = F.format_estimate_interval( estimate=decrease_infection_time.get_mean(), interval=decrease_infection_time.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average decrease in infection duration " "and {:.{prec}%} CI:".format(1 - Settings.ALPHA, prec=0), estimate_CI) # increase in discounted total cost under combination therapy with respect to mono therapy increase_discounted_cost = Stat.DifferenceStatIndp( name='Increase in discounted cost', x=simOutputs_SEMI.get_costs(), y_ref=simOutputs_ANNUAL.get_costs()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_discounted_cost.get_mean(), interval=increase_discounted_cost.get_t_CI(alpha=Settings.ALPHA), deci=0, form=F.FormatNumber.CURRENCY) print( "Average increase in discounted cost " "and {:.{prec}%} CI:".format(1 - Settings.ALPHA, prec=0), estimate_CI) # increase in discounted total utility under combination therapy with respect to mono therapy increase_discounted_utility = Stat.DifferenceStatIndp( name='Increase in discounted cost', x=simOutputs_SEMI.get_utilities(), y_ref=simOutputs_ANNUAL.get_utilities()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_discounted_utility.get_mean(), interval=increase_discounted_utility.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average increase in discounted utility " "and {:.{prec}%} CI:".format(1 - Settings.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes(simOutputs_warfarin, simOutputs_Dabigitran150): """ prints average increase in survival time, discounted cost, and discounted utility under dab therapy compared to warf therapy :param simOutputs_warfarin: output of a cohort simulated under warfarin therapy :param simOutputs_Dabigitran150: output of a cohort simulated under dab therapy """ # increase in survival time under dab therapy with respect to warf therapy increase_survival_time = Stat.DifferenceStatIndp( name="Increase in survival time", x=simOutputs_Dabigitran150.get_survival_times(), y_ref=simOutputs_warfarin.get_survival_times()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_survival_time.get_mean(), interval=increase_survival_time.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average increase in survival time " "and {:.{prec}%} CI:".format(1 - Settings.ALPHA, prec=0), estimate_CI) # increase in discounted total cost under dab therapy with respect to warfarin therapy increase_discounted_cost = Stat.DifferenceStatIndp( name='Increase in discounted cost', x=simOutputs_Dabigitran150.get_costs(), y_ref=simOutputs_warfarin.get_costs()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_discounted_cost.get_mean(), interval=increase_discounted_cost.get_t_CI(alpha=Settings.ALPHA), deci=0, form=F.FormatNumber.CURRENCY) print( "Average increase in discounted cost " "and {:.{prec}%} CI:".format(1 - Settings.ALPHA, prec=0), estimate_CI) # increase in discounted total utility under dab therapy with respect to warfarin therapy increase_discounted_utility = Stat.DifferenceStatIndp( name='Increase in discounted cost', x=simOutputs_Dabigitran150.get_utilities(), y_ref=simOutputs_warfarin.get_utilities()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_discounted_utility.get_mean(), interval=increase_discounted_utility.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average increase in discounted utility " "and {:.{prec}%} CI:".format(1 - Settings.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes(simOutputs_A, simOutputs_B): # prints average increase in survival time, discounted cost, and discounted utility # increase in survival time comparing two therapies increase_survival_time = Stat.DifferenceStatIndp( name="Increase in survival time", x=simOutputs_B.get_survival_times(), y_ref=simOutputs_A.get_survival_times()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_survival_time.get_mean(), interval=increase_survival_time.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average increase in survival time " "and {:.{prec}%} CI:".format(1 - Settings.ALPHA, prec=0), estimate_CI) # increase in discounted total cost comparing two therapies increase_discounted_cost = Stat.DifferenceStatIndp( name='Increase in discounted cost', x=simOutputs_B.get_costs(), y_ref=simOutputs_A.get_costs()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_discounted_cost.get_mean(), interval=increase_discounted_cost.get_t_CI(alpha=Settings.ALPHA), deci=0, form=F.FormatNumber.CURRENCY) print( "Average increase in discounted cost " "and {:.{prec}%} CI:".format(1 - Settings.ALPHA, prec=0), estimate_CI) # increase in discounted total utility comparing two therapies increase_discounted_utility = Stat.DifferenceStatIndp( name='Increase in discounted cost', x=simOutputs_B.get_utilities(), y_ref=simOutputs_A.get_utilities()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_discounted_utility.get_mean(), interval=increase_discounted_utility.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average increase in discounted utility " "and {:.{prec}%} CI:".format(1 - Settings.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes(simOutputs_mono, simOutputs_combo): """ prints average increase in survival time, discounted cost, and discounted utility under combination therapy compared to mono therapy :param simOutputs_mono: output of a cohort simulated under mono therapy :param simOutputs_combo: output of a cohort simulated under combination therapy """ # increase in survival time under combination therapy with respect to mono therapy if Settings.PSA_ON: increase_survival_time = Stat.DifferenceStatPaired( name='Increase in survival time', x=simOutputs_combo.get_survival_times(), y_ref=simOutputs_mono.get_survival_times()) else: increase_survival_time = Stat.DifferenceStatIndp( name='Increase in survival time', x=simOutputs_combo.get_survival_times(), y_ref=simOutputs_mono.get_survival_times()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_survival_time.get_mean(), interval=increase_survival_time.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average increase in survival time " "and {:.{prec}%} confidence interval:".format(1 - Settings.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes(sim_output_no_drug, sim_output_with_drug): """ prints expected and percentage increase in survival time when drug is available :param sim_output_no_drug: output of a fair game :param sim_output_with_drug: output of an unfair game """ # increase in survival time increase = Stat.DifferenceStatIndp(name='Increase in casino rewards', x=sim_output_with_drug.get_rewards(), y_ref=sim_output_no_drug.get_rewards()) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=P.ALPHA), deci=1) print( "Average increase in casino rewards and {:.{prec}%} confidence interval:" .format(1 - P.ALPHA, prec=0), estimate_CI) # % increase in survival time relative_diff = Stat.RelativeDifferenceIndp( name='Average % increase in casino rewards', x=sim_output_with_drug.get_rewards(), y_ref=sim_output_no_drug.get_rewards()) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=relative_diff.get_mean(), interval=relative_diff.get_bootstrap_CI(alpha=P.ALPHA, num_samples=1000), deci=1, form=Format.FormatNumber.PERCENTAGE) print( "Average percentage increase in casino rewards and {:.{prec}%} confidence interval:" .format(1 - P.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes(sim_output_fair_coins, sim_output_unfair_coins): """ prints expected and percentage increase in survival time when drug is available :param sim_output_no_drug: output of a cohort simulated when drug is not available :param sim_output_with_drug: output of a cohort simulated when drug is available """ # increase in rewards increase = Stat.DifferenceStatIndp( name='Increase in survival time', x=sim_output_unfair_coins.get_rewards(), y_ref=sim_output_fair_coins.get_rewards()) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=P.ALPHA), deci=1) print( "Average increase in rewards for casino owners and {:.{prec}%} confidence interval" " when using unfair coins:".format(1 - P.ALPHA, prec=0), estimate_CI) # % increase in rewards relative_diff = Stat.RelativeDifferenceIndp( name='Average % increase in survival time', x=sim_output_unfair_coins.get_rewards(), y_ref=sim_output_fair_coins.get_rewards()) # estimate and CI estimate_CI2 = Format.format_estimate_interval( estimate=-relative_diff.get_mean(), interval=-relative_diff.get_bootstrap_CI(alpha=P.ALPHA, num_samples=1000), deci=1, form=Format.FormatNumber.PERCENTAGE) print( "Average percentage of increase rewards for casino owners and {:.{prec}%} confidence interval" " when using unfair coins:".format(1 - P.ALPHA, prec=0), estimate_CI2)
def print_comparative_outcomes(simOutputs_no_therapy, simOutputs_anticoagulation): """ :param simOutputs_no_therapy: :param simOutputs_anticoagulation: :return: """ # increase in survival time under anticoagulation therapy with respect to no therapy if Settings.PSA_ON: increase_survival_time = Stat.DifferenceStatPaired( name='Increase in survival time', x=simOutputs_anticoagulation.get_survival_times(), y_ref=simOutputs_no_therapy.get_survival_times()) else: increase_survival_time = Stat.DifferenceStatIndp( name='Increase in survival time', x=simOutputs_anticoagulation.get_survival_times(), y_ref=simOutputs_no_therapy.get_survival_times()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_survival_time.get_mean(), interval=increase_survival_time.get_t_CI(alpha=Settings.ALPHA), deci=2) print("Average increase in survival time " "and {:.{prec}%} confidence interval:".format(1 - Settings.ALPHA, prec=0), estimate_CI)
def get_CI(self, wtp, alpha): # reform 2 independent variables to pass in DifferenceStatIndp class stat_new = wtp * self._healthNew - self._costNew stat_base = wtp * self._healthBase - self._costBase # to get CI for stat_new - stat_base diff_stat = Stat.DifferenceStatIndp(self._name, stat_new, stat_base) return diff_stat.get_t_CI(alpha)
def print_comparative_outcomes(sim_output_high, sim_output_low): # increase in survival time increase = Stat.DifferenceStatIndp(name='Increase in game score', x=sim_output_high, y_ref=sim_output_low) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=0.05), deci=1) print( "Average increase in game score and {:.{prec}%} confidence interval:". format(1 - 0.05, prec=0), estimate_CI) # % increase in survival time relative_diff = Stat.RelativeDifferenceIndp( name='Average % increase in game score', x=sim_output_high, y_ref=sim_output_low) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=relative_diff.get_mean(), interval=relative_diff.get_bootstrap_CI(alpha=0.05, num_samples=1000), deci=1, form=Format.FormatNumber.PERCENTAGE) print( "Average percentage increase in game score and {:.{prec}%} confidence interval:" .format(1 - 0.05, prec=0), estimate_CI)
def print_comparative_outcomes(sim_output_unfair, sim_output_fair): increase = Stat.DifferenceStatIndp(name='Increase in rewards', x=sim_output_unfair.get_rewards(), y_ref=sim_output_fair.get_rewards()) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=P.ALPHA), deci=1) print( "Average increase in reward and {:.{prec}%} confidence interval:". format(1 - P.ALPHA, prec=0), estimate_CI) # % increase in survival time relative_diff = Stat.RelativeDifferenceIndp( name='Average % increase in rewards', x=sim_output_unfair.get_rewards(), y_ref=sim_output_fair.get_rewards()) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=relative_diff.get_mean(), interval=relative_diff.get_bootstrap_CI(alpha=P.ALPHA, num_samples=1000), deci=1, form=Format.FormatNumber.PERCENTAGE) print( "Average percentage increase in reward and {:.{prec}%} confidence interval:" .format(1 - P.ALPHA, prec=0), estimate_CI)
def get_compare(sim_output_fair, sim_output_unfair): increase = Stat.DifferenceStatIndp(name='Increase in Reward', x=sim_output_fair.get_rewards(), y_ref=sim_output_unfair.get_rewards()) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=alpha), deci=1) print( "Average increase in reward ($) and {:.{prec}%} confidence interval:". format(1 - alpha, prec=0), estimate_CI)
def print_comparative_outcomes(sim_output_unfair_game, sim_output_fair_game): increase = Stat.DifferenceStatIndp(name='Increase in game rewards', x=sim_output_unfair_game(), y_ref=sim_output_fair_game()) estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=P.ALPHA), deci=1) print( "Average increase in game rewards and {:.{prec}%} confidence interval:" .format(1 - P.ALPHA, prec=1), estimate_CI)
def print_comparative_outcomes(multi_cohort_unfair, multi_cohort_fair): increase = Stat.DifferenceStatIndp( name='Increase in mean reward', x=multi_cohort_unfair.get_all_total_rewards(), y_ref=multi_cohort_fair.get_all_total_rewards()) # estimate and prediction interval estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_PI(alpha=P.ALPHA), deci=1) print( "Expected increase in mean survival time (years) and {:.{prec}%} prediction interval:" .format(1 - P.ALPHA, prec=0), estimate_CI)
def get_compare(sim_output_fair, sim_output_unfair): increase = Stat.DifferenceStatIndp( name='Increase in Reward', x=sim_output_fair.get_mean_total_reward(), y_ref=sim_output_unfair.get_mean_total_reward() ) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_PI(alpha=alpha), deci=1 ) print("Expected increase in reward ($) and {:.{prec}%} prediction interval:".format(1 - alpha, prec=0), estimate_CI)
def print_comparative_outcomes(Fair, Unfair): # increase in rewards increase = Stat.DifferenceStatIndp(name='Increase in rewards', x=Unfair.get_all_total_rewards(), y_ref=Fair.get_all_total_rewards()) # estimate and prediction interval estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_PI(alpha=0.05), deci=1) print( "Expected increase in total rewards ($) and {:.{prec}%} prediction interval:" .format(1 - 0.05, prec=0), estimate_CI)
def print_comparative_outcomes(sim_output_fair_coin, sim_output_unfair_coin): difference = Stat.DifferenceStatIndp( name='Change in game rewards', x=sim_output_unfair_coin.get_rewards(), y_ref=sim_output_fair_coin.get_rewards() ) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=difference.get_mean(), interval=difference.get_t_CI(alpha=P.ALPHA), deci=1 ) print("Average change in game rewards and {:.{prec}%} confidence interval:".format(1 - P.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes(multi_cohort_fair_coin, multi_cohort_unfair_coin): difference = Stat.DifferenceStatIndp( name='Change in expected reward', x=multi_cohort_unfair_coin.get_all_mean_reward(), y_ref=multi_cohort_fair_coin.get_all_mean_reward()) estimate_CI = Format.format_estimate_interval( estimate=difference.get_mean(), interval=difference.get_t_CI(alpha=P.ALPHA), deci=1) print( "Expected change in mean game reward and {:.{prec}%} prediction interval:" .format(1 - P.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes(sim_output_fair, sim_output_unfair): # increase in payout increase = Stat.DifferenceStatIndp( name='Difference in payout', x=sim_output_unfair.get_all_mean_payouts(), y_ref=sim_output_fair.get_all_mean_payouts()) # estimate and CI estimate = Format.format_estimate_interval(estimate=increase.get_mean(), interval=increase.get_t_CI( P.ALPHA), deci=2) print( 'Expected difference in payout (dollars) and {:.{prec}%} PI:'.format( 1 - P.ALPHA, prec=0), estimate)
def print_comparative_outcomes(sim_output_fair, sim_output_unfair): """ prints expected and percentage increase in payout when unfair coin is used""" # increase in payout increase = Stat.DifferenceStatIndp(name='Difference in payout', x=sim_output_unfair.get_payouts(), y_ref=sim_output_fair.get_payouts()) # estimate and CI Estimate = Format.format_estimate_interval(estimate=increase.get_mean(), interval=increase.get_t_CI( P.ALPHA), deci=2) print( 'Average change in payout (dollars) and {:.{prec}%} confidence interval:' .format(1 - P.ALPHA, prec=0), Estimate)
def print_comparative_outcomes(multi_cohort_unfair_game, multi_cohort_fair_game): increase = Stat.DifferenceStatIndp(name='Increase in mean game reward', x=multi_cohort_unfair_game(), y_ref=multi_cohort_fair_game()) #estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=P.ALPHA), deci=1) print( "Expected increase in mean game reward and {:.{prec}%} prediction interval:" .format(1 - P.ALPHA, prec=1), estimate_CI)
def outcomes_comparative(games_fair_coin, games_biased_coin): ##prints the expected increase in game rewards when the coin is biased # what is the increase in game reward? increase = Stat.DifferenceStatIndp( name='Increase in gambler game reward', x=games_biased_coin.get_all_total_rewards(), y_ref=games_fair_coin.get_all_total_rewards()) # estimate and PI estimatePI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_PI(alpha=P.alpha), deci=1) print( " The average increase in gambler's total reward from 10 games and {:.{prec}%} projection interval:" .format(1 - P.alpha, prec=0), estimatePI)
def outcomes_comparative(output_fair_coin, output_biased_coin): ##prints the expected increase in game rewards when the coin is biased # what is the increase in game reward? increaseReward = Stat.DifferenceStatIndp( name='Increase in game reward', x=output_biased_coin.get_rewards(), y_ref=output_fair_coin.get_rewards()) # estimate and CI estimateCI = Format.format_estimate_interval( estimate=increaseReward.get_mean(), interval=increaseReward.get_t_CI(alpha=P.alpha), deci=1) print( " The expected increase in gambler's total reward from playing 10 games and {:.{prec}%} confidence interval:" .format(1 - P.alpha, prec=0), estimateCI)
def print_comparative_outcomes(NoTherapy, Therapy): # increase in discounted total utility under combination therapy with respect to mono therapy increase_discounted_utility = Stat.DifferenceStatIndp( name='Increase in discounted utility', x=Therapy.get_utilities(), y_ref=NoTherapy.get_utilities()) # estimate and CI estimate_CI = F.format_estimate_interval( estimate=increase_discounted_utility.get_mean(), interval=increase_discounted_utility.get_t_CI(alpha=Settings.ALPHA), deci=2) print( "Average increase in discounted utility " "and {:.{prec}%} confidence interval:".format(1 - Settings.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes_transientstate(unfair_coin, fair_coin): """ prints expected change in winnings when coin is unfair available """ # change in winnings increase = Stat.DifferenceStatIndp( name='Change in average reward', x=unfair_coin.get_winningslist(), y_ref=fair_coin.get_winningslist() ) # estimate and prediction interval estimate_PI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_PI(alpha=0.05), deci=1 ) print("Expected change in mean reward (dollars) and {:.{prec}%} prediction interval:".format(1 - 0.05, prec=0), estimate_PI)
def print_comparative_outcomes(multi_cohort_fair, multi_cohort_unfair): """ prints expected and percentage increase in average survival time when drug is available :param multi_cohort_no_drug: multiple cohorts simulated when drug is not available :param multi_cohort_with_drug: multiple cohorts simulated when drug is available """ increase = Stat.DifferenceStatIndp( name='Increase in mean reward', x=multi_cohort_unfair.get_all_total_rewards(), y_ref=multi_cohort_fair.get_all_total_rewards()) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=P.ALPHA), deci=1) print( "Expected increase in mean reward and {:.{prec}%} prediction interval:" .format(1 - P.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes(sim_output_no_drug, sim_output_with_drug): """ prints expected and percentage increase in survival time when drug is available :param sim_output_no_drug: output of a cohort simulated when drug is not available :param sim_output_with_drug: output of a cohort simulated when drug is available """ # increase in survival time increase = Stat.DifferenceStatIndp(name='Increase in survival time', x=sim_output_with_drug.get_rewards(), y_ref=sim_output_no_drug.get_rewards()) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=P.ALPHA), deci=1) print( "Average increase in reward (dollars) and {:.{prec}%} confidence interval:" .format(1 - P.ALPHA, prec=0), estimate_CI)
def print_comparative_outcomes(cohort1, cohort2, alpha): """ :param cohort1: :param cohort2: :return: """ # increase in survival time increase = Stat.DifferenceStatIndp(name='Increase in mean rewards', x=cohort1.get_all_total_rewards(), y_ref=cohort2.get_all_total_rewards()) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=alpha), deci=1) print( "Expected increase in mean rewards and {:.{prec}%} prediction interval:" .format(1 - alpha, prec=0), estimate_CI)
def print_comparative_outcomes(sim_output_fair_coin, sim_output_unfair_coin): """ prints the expected increase in game rewards when the coin is unfair :param sim_output_fair_coin: output of a set of games simulated when the coin if fair :param sim_output_unfair_coin: output of a set of games simulated when the coin is unfair """ # increase in game reward increase = Stat.DifferenceStatIndp( name='Increase in game reward', x=sim_output_unfair_coin.get_rewards(), y_ref=sim_output_fair_coin.get_rewards()) # estimate and CI estimate_CI = Format.format_estimate_interval( estimate=increase.get_mean(), interval=increase.get_t_CI(alpha=P.alpha), deci=1) print( "The average increase in game reward and {:.{prec}%} confidence interval:" .format(1 - P.alpha, prec=0), estimate_CI)