def draw_survival_curves_and_histograms(simOutputs_mono, simOutputs_combo): """ draws the survival curves and the histograms of time until HIV deaths :param simOutputs_mono: output of a cohort simulated under mono therapy :param simOutputs_combo: output of a cohort simulated under combination therapy """ # get survival curves of both treatments survival_curves = [ simOutputs_mono.get_survival_curve(), simOutputs_combo.get_survival_curve() ] # graph survival curve PathCls.graph_sample_paths(sample_paths=survival_curves, title='Survival curve', x_label='Simulation time step (year)', y_label='Number of alive patients', legends=['Mono Therapy', 'Combination Therapy']) # histograms of survival times set_of_survival_times = [ simOutputs_mono.get_survival_times(), simOutputs_combo.get_survival_times() ] # graph histograms Figs.graph_histograms(data_sets=set_of_survival_times, title='Histogram of patient survival time', x_label='Survival time (year)', y_label='Counts', bin_width=1, legend=['Mono Therapy', 'Combination Therapy'], transparency=0.6)
def draw_survival_curves_and_histograms(sim_output_no_drug, sim_output_with_drug): """ draws the survival curves and the histograms of survival time :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 """ # get survival curves of both treatments survival_curves = [ sim_output_no_drug.get_survival_curve(), sim_output_with_drug.get_survival_curve() ] # graph survival curve PathCls.graph_sample_paths(sample_paths=survival_curves, title='Survival curve', x_label='Simulation time step', y_label='Number of alive patients', legends=['No Drug', 'With Drug']) # histograms of survival times set_of_survival_times = [ sim_output_no_drug.get_survival_times(), sim_output_with_drug.get_survival_times() ] # graph histograms Figs.graph_histograms(data_sets=set_of_survival_times, title='Histogram of patient survival time', x_label='Survival time', y_label='Counts', bin_width=1, legend=['No Drug', 'With Drug'], transparency=0.6)
def draw_survival_curves_and_histograms(simOutputs_standard, simOutputs_population): """ draws the survival curves and the histograms of time until cancer :param simOutputs_standard: output of a cohort simulated under standard testing :param simOutputs_population: output of a cohort simulated under population testing """ # get survival curves of both treatments survival_curves = [ simOutputs_standard.get_survival_curve(), simOutputs_population.get_survival_curve() ] # graph survival curve PathCls.graph_sample_paths( sample_paths=survival_curves, title='Survival curve', x_label='Simulation time step (year)', y_label='Number of alive patients', legends=['Standard Testing', 'Population Testing']) # histograms of survival times set_of_survival_times = [ simOutputs_standard.get_survival_times(), simOutputs_population.get_survival_times() ] # graph histograms Figs.graph_histograms(data_sets=set_of_survival_times, title='Histogram of patient survival time', x_label='Survival time (year)', y_label='Counts', bin_width=1, legend=['Mono Therapy', 'Combination Therapy'], transparency=0.6)
def draw_survival_curves_and_histograms(simOutputs_warfarin, simOutputs_Dabigitran150): """ draws the survival curves and the histograms of time until stoke deaths :param simOutputs_warfarin: output of a cohort simulated under warfarin therapy :param simOutputs_Dabigitran150: output of a cohort simulated under dab150 therapy """ # get survival curves of both treatments survival_curves = [ simOutputs_warfarin.get_survival_curve(), simOutputs_Dabigitran150.get_survival_curve() ] # graph survival curve PathCls.graph_sample_paths(sample_paths=survival_curves, title='Survival curve', x_label='Simulation time step (year)', y_label='Number of alive patients', legends=['Warfarin', 'Dabigitran150 Therapy']) # histograms of survival times set_of_survival_times = [ simOutputs_warfarin.get_survival_times(), simOutputs_Dabigitran150.get_survival_times() ] # graph histograms Figs.graph_histograms(data_sets=set_of_survival_times, title='Histogram of patient survival time', x_label='Survival time (year)', y_label='Counts', bin_width=1, legend=['Warfarin Therapy', 'Dabigitran150 Therapy'], transparency=0.6)
def draw_infection_curves_and_histograms(simOutputs_ANNUAL, simOutputs_SEMI): """ draws the infection curves and the histograms of time until HIV deaths :param simOutputs_mono: output of a cohort simulated under mono therapy :param simOutputs_combo: output of a cohort simulated under combination therapy """ # histograms of infection times set_of_infection_times = [ simOutputs_ANNUAL.get_infection_durations(), simOutputs_SEMI.get_infection_durations() ] # graph histograms Figs.graph_histograms(data_sets=set_of_infection_times, title='Histogram of Infection Duration', x_label='Infection Duration (Year)', y_label='Counts', bin_width=1, legend=['Annual Treatment', 'Semi-Annual Treatment'], transparency=0.6) #get infection curves of both treatments infection_curves = [ simOutputs_ANNUAL.get_infection_curve(), simOutputs_SEMI.get_infection_curve() ] # graph infection curve PathCls.graph_sample_paths(sample_paths=infection_curves, title='infection curve', x_label='Simulation time step (year)', y_label='Number of infected patients', legends=['ANNUAL', '6-month'])
def draw_survival_curves_and_histograms(simOutputs_mono, simOutputs_combo): """ draws the survival curves and the histograms of time until HIV deaths :param simOutputs_mono: output of a cohort simulated under mono therapy :param simOutputs_combo: output of a cohort simulated under combination therapy """ # get survival curves of both treatments survival_curves = [ simOutputs_mono.get_survival_curve(), simOutputs_combo.get_survival_curve() ] # graph survival curve PathCls.graph_sample_paths(sample_paths=survival_curves, title='Exposure of antibiotics', x_label='Simulation time step (day)', y_label='Number of patients using antibiotics', legends=['Standard treatment', 'PCT-guided']) # histograms of survival times set_of_survival_times = [ simOutputs_mono.get_survival_times(), simOutputs_combo.get_survival_times() ] # graph histograms Figs.graph_histograms(data_sets=set_of_survival_times, title='Histogram of exposure time to antibiotics', x_label='Exposure time to antibiotics (day)', y_label='Counts', bin_width=1, legend=['Standard care', 'PCT-guided'], transparency=0.5)
def draw_survival_curves_and_histograms(simOutputs_none, simOutputs_anticoag): """ draws the survival curves and the histograms of time until HIV deaths :param simOutputs_none: output of a cohort simulated under the natural history of disease :param simOutputs_anticoag: output of a cohort simulated under angicoagulation therapy recepit """ # get survival curves of both treatments survival_curves = [ simOutputs_none.get_survival_curve(), simOutputs_anticoag.get_survival_curve() ] # graph survival curve PathCls.graph_sample_paths( sample_paths=survival_curves, title='Survival curve', x_label='Simulation time step (year)', y_label='Number of alive patients', legends=['No Therapy', 'Anticoagulation Therapy']) # histograms of survival times set_of_survival_times = [ simOutputs_none.get_survival_times(), simOutputs_anticoag.get_survival_times() ] # graph histograms Figs.graph_histograms(data_sets=set_of_survival_times, title='Histogram of patient survival time', x_label='Survival time (year)', y_label='Counts', bin_width=1, legend=['No Therapy', 'Anticoagulation Therapy'], transparency=0.6) # histograms of the number of strokes set_of_stroke_counts = [ simOutputs_none.get_if_developed_stroke(), simOutputs_anticoag.get_if_developed_stroke() ] # graph histograms Figs.graph_histograms(data_sets=set_of_stroke_counts, title='Histogram of patient stroke counts', x_label='Number of strokes', y_label='Counts', bin_width=1, legend=['No Therapy', 'Anticoagulation Therapy'], transparency=0.6)
def draw_stroke_histograms(simOutputs_none, simOutputs_anticoag): set_of_strokes = [ simOutputs_none.get_numbers_of_strokes(), simOutputs_anticoag.get_numbers_of_strokes() ] Figs.graph_histograms( data_sets=set_of_strokes, title='Histogram of number of strokes', x_label='Number of Strokes', y_label='Counts', bin_width=1, legend=['No Therapy', 'Anticoagulation Therapy'], transparency=0.6 )
def draw_reward_histograms(sim_output_fair_coin, sim_output_unfair_coin): set_of_game_rewards = [ sim_output_fair_coin.get_rewards(), sim_output_unfair_coin.get_rewards() ] Fig.graph_histograms( data_sets=set_of_game_rewards, title='Histogram of game reward', x_label='Game rewards', y_label='Counts', bin_width=50, legend=['Fair Coin', 'Unfair Coin'], transparency=0.6 )
def draw_histogram(sim_output_fair, sim_output_unfair): # histograms of payouts set_of_payouts = [ sim_output_fair.get_payouts(), sim_output_unfair.get_payouts() ] # graph histograms Fig.graph_histograms(data_sets=set_of_payouts, title='Histogram of payouts', x_label='Payouts', y_label='Counts', bin_width=50, legend=['Fair Coin', 'Unfair Coin'], transparency=0.6)
def make_plots(output_fair_coin, output_biased_coin): # makes histogram of the game rewards # histograms of game rewards set_of_game_rewards = [ output_fair_coin.get_rewards(), output_biased_coin.get_rewards() ] Figs.graph_histograms(data_sets=set_of_game_rewards, title='Histogram of Game Rewards', x_label='Game rewards', y_label='Counts', bin_width=20, legend=['Fair coin', 'Unfair coin'], transparency=0.6)
def draw_histograms(multiGames1, multiGames2): # histograms of average rewards set_of_rewards = [ multiGames1.get_all_total_rewards(), multiGames2.get_all_total_rewards() ] # graph histograms Figs.graph_histograms(data_sets=set_of_rewards, title='Histogram of total rewards (in 10 games)', x_label='Rewards', y_label='Counts', bin_width=15, legend=['50%', '45%'], transparency=0.5, x_range=[-1500, 1000])
def draw_histograms(multi_cohort_fair_coin, multi_cohort_unfair_coin): set_of_game_rewards = [ multi_cohort_fair_coin.get_all_mean_reward(), multi_cohort_unfair_coin.get_all_mean_reward() ] # graph histograms Fig.graph_histograms( data_sets=set_of_game_rewards, title='Histogram of average game reward', x_label='Game reward', y_label='Counts', bin_width=50, legend=['Fair Coin', 'Unfair Coin'], transparency=0.5, # x_range=[-50, 0] )
def make_plots(games_fair_coin, games_biased_coin): # histograms of total game rewards set_of_game_rewards = [ games_fair_coin.get_all_total_rewards(), games_biased_coin.get_all_total_rewards() ] # graph histograms Figs.graph_histograms( data_sets=set_of_game_rewards, title="Histogram of the Gambler's Total Rewards from 10 Games", x_label='Total Rewards', y_label='Count', bin_width=40, legend=['Fair coin', 'Unfair coin'], transparency=0.6, )
def draw_histograms(multi_cohort_fair, multi_cohort_unfair): """ draws the histograms of average survival time :param multi_cohort_fair: multiple cohorts simulated when using fair coins :param multi_cohort_unfair: multiple cohorts simulated when using unfair coins """ # histograms of average survival times set_of_game_rewards = [ multi_cohort_fair.get_all_total_rewards(), multi_cohort_unfair.get_all_total_rewards() ] # graph histograms Figs.graph_histograms(data_sets=set_of_game_rewards, title='Histogram of average game rewards', x_label='Game rewards', y_label='Counts', legend=['Fair coin', 'Unfair coin'], transparency=0.5, x_range=[0, 20])
def draw_survival_curves_and_histograms(sim_output_fair_coin, sim_output_unfair_coin): """ draws the histograms of game rewards :param sim_output_fair_coin: output of a set of games simulated when the coin is fair :param sim_output_unfair_coin: output of a set of games simulated when the coin is unfair """ # histograms of game rewards set_of_game_rewards = [ sim_output_fair_coin.get_rewards(), sim_output_unfair_coin.get_rewards() ] # graph histograms Figs.graph_histograms(data_sets=set_of_game_rewards, title='Histogram of Game Rewards', x_label='Game rewards', y_label='Counts', bin_width=20, legend=['Fair coin', 'Unfair coin'], transparency=0.6)
def draw_histograms(multi_games_fair_coin, multi_games_unfair_coin): """ draws the histograms of average game rewards :param multi_games_fair_coin: multiple sets of games simulated when the coin is fair :param multi_games_unfair_coin: multiple sets of games simulated when the coin is unfair """ # histograms of average game rewards set_of_game_rewards = [ multi_games_fair_coin.get_all_total_rewards(), multi_games_unfair_coin.get_all_total_rewards() ] # graph histograms Figs.graph_histograms( data_sets=set_of_game_rewards, title="Histogram of the Gambler's Average Total Game Rewards", x_label='Mean Game Rewards', y_label='Count', bin_width=40, legend=['Fair coin', 'Unfair coin'], transparency=0.6, )
def draw_survival_curves_and_histograms(sim_output_1, sim_output_2): """ draws the survival curves and the histograms of survival time :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 """ # histograms of rewards set_of_rewards = [ sim_output_1.get_rewards(), sim_output_2.get_rewards() ] # graph histograms Figs.graph_histograms( data_sets=set_of_rewards, title='Histogram of rewards', x_label='Rewards', y_label='Counts', bin_width=15, legend=['50%', '45%'], transparency=0.6 )
def draw_histograms(multigamesetsfair, multigamesetsunfair): """ draws the histograms of average survival time :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 """ # histograms of average survival times totalreward = [ multigamesetsfair.get_all_total_rewards(), multigamesetsunfair.get_all_total_rewards() ] # graph histograms Figs.graph_histograms( data_sets= totalreward, title='Histogram of total reward', x_label='Reward', y_label='Counts', bin_width=50, legend=['Fair coin', 'Unfair coin'], transparency=0.5, )
def draw_reward_histograms(sim_output_fair_coin, sim_output_unfair_coin): """ draws the histograms of game rewards :param sim_output_fair_coin: output of a cohort simulated game-set with a fair coin :param sim_output_unfair_coin: output of a cohort simulated game-set with an unfair coin """ # histograms of game rewards set_of_game_rewards = [ sim_output_fair_coin.get_rewards(), sim_output_unfair_coin.get_rewards() ] # graph histograms Figs.graph_histograms( data_sets=set_of_game_rewards, title='Histogram of game reward', x_label='Game rewards', y_label='Counts', bin_width=50, legend=['Fair Coin', 'Unfair Coin'], transparency=0.6 )
def draw_survival_curves_and_histograms(simOutputs_no_therapy, simOutputs_anticoagulation): """ :param simOutputs_no_therapy: no therapy :param simOutputs_anticoagulation: anticoagulation :return: """ # get survival curves of both treatments survival_curves = [ simOutputs_no_therapy.get_survival_curve(), simOutputs_anticoagulation.get_survival_curve() ] # graph survival curve PathCls.graph_sample_paths( sample_paths=survival_curves, title='Survival curve', x_label='Simulation time step (year)', y_label='Number of alive patients', legends=['No Therapy', 'Anticoagulation Therapy'] ) # histograms of survival times set_of_survival_times = [ simOutputs_no_therapy.get_survival_times(), simOutputs_anticoagulation.get_survival_times() ] # graph histograms Figs.graph_histograms( data_sets=set_of_survival_times, title='Histogram of patient survival time', x_label='Survival time (year)', y_label='Counts', bin_width=1, legend=['No Therapy', 'Anticoagualtion Therapy'], transparency=0.6 )
def draw_histograms(multi_cohort_fair_coin, multi_cohort_unfair_coin): """ draws the histograms of average survival time :param multi_cohort_fair_coin: multiple gamesets simulated when the coin is fair :param multi_cohort_unfair_coin: multiple gamesets simulated when the coin is unfair """ # histograms of game rewards set_of_game_rewards = [ multi_cohort_fair_coin.get_all_mean_reward(), multi_cohort_unfair_coin.get_all_mean_reward() ] # graph histograms Figs.graph_histograms( data_sets=set_of_game_rewards, title='Histogram of average game reward', x_label='Game reward', y_label='Counts', bin_width=50, legend=['Fair Coin', 'Unfair Coin'], transparency=0.5, # x_range=[-50, 0] )
def draw_histograms(multi_cohort_UnfairCoin, multi_cohort_FairCoin): """ draws the histograms of average survival time :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 """ # histograms of average survival times set_of_survival_times = [ multi_cohort_UnfairCoin.get_mean_total_reward(), multi_cohort_FairCoin.get_mean_total_reward() ] # graph histograms Figs.graph_histograms( data_sets=set_of_survival_times, title='Histogram of average patient survival time', x_label='Survival time', y_label='Counts', bin_width=1, legend=['No Drug', 'With Drug'], transparency=0.5, x_range=[6, 20] )
def histograms(sim_output_fair_coin, sim_output_unfair_coin): """ draws the histograms of rewards :param sim_output_fair_coin: output of a set of games simulated with a fair coin :param sim_output_unfair_coin: output of a set of games simulated with an unfair coin """ # histograms of survival times set_of_rewards = [ sim_output_fair_coin.get_rewards(), sim_output_unfair_coin.get_rewards() ] # graph histograms Figs.graph_histograms( data_sets=set_of_rewards, title="Histogram of Rewards from 1000 Games obtained from the steady-state simulation model", x_label="Game Rewards", y_label="Frequency", bin_width=25, legend=['Fair Coin', 'Unfair Coin'], transparency=0.5 )
def draw_survival_curves_and_histograms(simOutputs_anti, simOutputs_none): """ draws the survival curves and the histograms of time until STROKE deaths :param simOutputs_anti: output of a cohort simulated under ANTI therapy :param simOutputs_none: output of a cohort simulated under NONE therapy """ # get survival curves of both treatments survival_curves = [ simOutputs_anti.get_survival_curve(), simOutputs_none.get_survival_curve() ] # graph survival curve PathCls.graph_sample_paths( sample_paths=survival_curves, title='Survival curve', x_label='Simulation time step (year)', y_label='Number of alive patients', legends=['Anticoagulant Therapy', 'None Therapy'] ) # histograms of survival times set_of_survival_times = [ simOutputs_anti.get_survival_times(), simOutputs_none.get_survival_times() ] # graph histograms Figs.graph_histograms( data_sets=set_of_survival_times, title='Histogram of patient survival time', x_label='Survival time (year)', y_label='Counts', bin_width=1, legend=['Anticoagulant Therapy', 'None Therapy'], transparency=0.6 )
def draw_survival_curves_and_histograms(simOutputs_warfarin, simOutputs_dabigatran_110, simOutputs_dabigatran_150): # draws the survival curves and the histograms of time until death # get survival curves of all treatments survival_curves = [ simOutputs_warfarin.get_survival_curve(), simOutputs_dabigatran_110.get_survival_curve(), simOutputs_dabigatran_150.get_survival_curve() ] # graph survival curve PathCls.graph_sample_paths( sample_paths=survival_curves, title='Survival curve', x_label='Simulation time step (year)', y_label='Number of alive patients', legends=['Warfarin', 'Dabigatran 110', 'Dabigatran 150']) # histograms of survival times set_of_survival_times = [ simOutputs_warfarin.get_survival_times(), simOutputs_dabigatran_110.get_survival_times(), simOutputs_dabigatran_150.get_survival_times() ] # graph histograms Figs.graph_histograms( data_sets=set_of_survival_times, title='Histogram of patient survival time', x_label='Survival time (year)', y_label='Counts', bin_width=0.5, legend=['Warfarin', 'Dabigatran 110', 'Dabigatran 150'], transparency=0.6)
##PLOT: cohortOUT_1 = CohortOutputs(cohort_1) cohortOUT_2 = CohortOutputs(cohort_2) survival_curves = [ cohortOUT_1.get_survival_curve(), cohortOUT_2.get_survival_curve() ] survival_curves = [ cohortOUT_1.get_survival_curve(), cohortOUT_2.get_survival_curve() ] PathCls.graph_sample_paths(sample_paths=survival_curves, title='Survival curve', x_label='Simulation time step', y_label='Number of alive patients', legends=['No Drug', 'With Drug']) set_STROKE_times = [ cohort_1.get_time_to_STROKE(), cohort_2.get_time_to_STROKE() ] Figs.graph_histograms(data_sets=set_STROKE_times, title='Histogram of patient STROKE time', x_label='Survival time', y_label='Counts', bin_width=1, legend=['WELL', 'POST DRUG'], transparency=0.6)
print(meansurvival, CI_of_Expected) print(meansurvival_TWO, CI_of_Expected_TWO) cohortOUT_ONE = CohortOutcomes(cohort_ONE) cohortOUT_TWO = CohortOutcomes(cohort_TWO) survival_curves = [ cohortOUT_ONE.get_survival_curve(), cohortOUT_TWO.get_survival_curve() ] PathCls.graph_sample_paths(sample_paths=survival_curves, title='Survival curve', x_label='Simulation time step', y_label='Number of alive patients', legends=['No Drug', 'With Drug']) set_of_STROKE_times = [ cohort_ONE.get_STROKE_time(), cohort_TWO.get_STROKE_time() ] Figs.graph_histograms(data_sets=set_of_STROKE_times, title='Histogram of patient STROKE time', x_label='Survival time', y_label='Counts', bin_width=1, legend=['No Drug', 'With Drug'], transparency=0.6)
import Q3 as NoAnticoag import Q5 as Anticoag import scr.FigureSupport as Fig NoAnticoag = NoAnticoag.CohortSim.get_number_strokes() Anticoag = Anticoag.CohortAnticoagSim.get_number_strokes() # generate histograms Fig.graph_histograms(data_sets=[NoAnticoag, Anticoag], title='Number of strokes', x_label='Number of strokes', y_label='Number of patients', legend=['No Anticoagulation', 'Anticoagulation'])