<jupyter_start><jupyter_text>Histograms of distribution differences<jupyter_code># (Optimal, Prior Btw, Prior below, Prior above, Uniform)
colors = ('#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99')
histColors = [colors[1], colors[-1]]
def get_subset_of_df(df, sample_size, prior_type, sampling_type, actual_arm_variance = None):
    mask = (df.sample_size == sample_size) & (df.prior_type == prior_type) \
                  & (df.sampling_type == sampling_type)
    if actual_arm_variance != None:
        mask = mask & (df.actual_arm_variance == actual_arm_variance)
    return df.loc[mask]

normalNonZeroES = pd.read_csv('/Users//banditalgorithms/data/normalNonZeroESPriorChanges24April2018ProbArmsDiffer.csv')
largeEffectUniformSampling = get_subset_of_df(normalNonZeroES, 52, 'priorBetween', 'uniform')
largeEffectBanditSampling = get_subset_of_df(normalNonZeroES, 52, '0', 'bandit')
normalZeroES = pd.read_csv('/Users//banditalgorithms/data/normalZeroESPriorChanges24April2018ProbArmsDiffer.csv')
noEffectUniformSampling = get_subset_of_df(normalZeroES, 52, 'priorBetween', 'uniform', 1.25)
noEffectBanditSampling = get_subset_of_df(normalZeroES, 52, 'priorBetween', 'bandit', 1.25)


print(largeEffectBanditSampling.shape)
weights = np.ones_like(noEffectUniformSampling.avg_difference)/float(noEffectUniformSampling.shape[0])

bins = np.linspace(0, 1, 101)
figure, axes = plt.subplots(1, 4, figsize = (20,4))
axes[0].hist(largeEffectUniformSampling.loc[:,'prob_bigger'], bins, alpha=0.6,color = colors[-1], label='Uniform assignment', weights=weights)
axes[0].hist(largeEffectBanditSampling.loc[:,'prob_bigger'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[0].legend(loc='upper left')
axes[0].set_ylabel('Proportion of simulations')
axes[0].set_title('Condition 1 > Condition 2\n(Large effect size)')
axes[0].set_xlabel('Probability Cond 1. > Cond. 2')
bins = np.linspace(-3, 3, 101)
axes[1].hist(largeEffectUniformSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[1].hist(largeEffectBanditSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[1].set_title('Expected Difference\n(True difference = 1)')
axes[1].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[1].set_xticks(range(-2,3,1))

bins = np.linspace(0, 1, 101)
axes[2].hist(noEffectUniformSampling.loc[:,'prob_bigger'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[2].hist(noEffectBanditSampling.loc[:,'prob_bigger'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[2].set_title('Condition 1 > Condition 2\n(Zero effect size)')
axes[2].set_xlabel('Probability Cond 1. > Cond. 2')

bins = np.linspace(-2.5, 2.5, 101)
axes[3].hist(noEffectUniformSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[3].hist(noEffectBanditSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[3].set_title('Expected Difference\n(True difference = 0)')
axes[3].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[3].set_xticks(range(-2,3,1))

legend_anchor=(1.3, 1.45)
axes[0].legend(ncol=2, bbox_to_anchor=legend_anchor)

starting_label_x = 0.1
label_y = 0
label_x_increment = 0.2025
for i in range(4):
    plt.gcf().text(starting_label_x+i*label_x_increment, label_y, \
                   '(' + chr(ord('a')+i) + ')', fontsize=16)
plt.subplots_adjust(wspace=0.2)
figure.savefig(outdir_prefix+date_prefix+'HistogramConditionDiff.pdf', bbox_inches='tight')
normalNonZeroES = pd.read_csv('/Users//banditalgorithms/data/normalNonZeroESPriorChanges24April2018ProbArmsDiffer.csv')
largeEffectUniformSampling = get_subset_of_df(normalNonZeroES, 52, 'priorBetween', 'uniform')
largeEffectBanditSampling = get_subset_of_df(normalNonZeroES, 52, '0', 'bandit')
normalZeroES = pd.read_csv('/Users//banditalgorithms/data/normalZeroESPriorChanges24April2018ProbArmsDiffer.csv')
noEffectUniformSampling = get_subset_of_df(normalZeroES, 52, 'priorBetween', 'uniform', 1.25)
noEffectBanditSampling = get_subset_of_df(normalZeroES, 52, 'priorBetween', 'bandit', 1.25)


print(largeEffectBanditSampling.shape)
weights = np.ones_like(noEffectUniformSampling.avg_difference)/float(noEffectUniformSampling.shape[0])

bins = np.linspace(0, 1, 101)
# figure, axes = plt.subplots(1, 4, figsize = (20,4))
figure, axes = plt.subplots(2, 2, figsize = (12,8))

axes[0,0].hist(largeEffectUniformSampling.loc[:,'prob_bigger'], bins, alpha=0.6,color = colors[-1], label='Uniform assignment', weights=weights)
axes[0,0].hist(largeEffectBanditSampling.loc[:,'prob_bigger'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[0,0].legend(loc='upper left')
axes[0,0].set_title('Condition 1 > Condition 2\n(Large effect size)')
axes[0,0].set_xlabel('Probability Cond 1. > Cond. 2')
bins = np.linspace(-3, 3, 101)
axes[0,1].hist(largeEffectUniformSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[0,1].hist(largeEffectBanditSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[0,1].set_title('Expected Difference\n(True difference = 1)')
axes[0,1].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[0,1].set_xticks(range(-2,3,1))

bins = np.linspace(0, 1, 101)
axes[1,0].hist(noEffectUniformSampling.loc[:,'prob_bigger'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[1,0].hist(noEffectBanditSampling.loc[:,'prob_bigger'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[1,0].set_title('Condition 1 > Condition 2\n(Zero effect size)')
axes[1,0].set_xlabel('Probability Cond 1. > Cond. 2')

bins = np.linspace(-2.5, 2.5, 101)
axes[1,1].hist(noEffectUniformSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[1,1].hist(noEffectBanditSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[1,1].set_title('Expected Difference\n(True difference = 0)')
axes[1,1].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[1,1].set_xticks(range(-2,3,1))

legend_anchor=(1.3, 1.6)
axes[0,0].legend(ncol=2, bbox_to_anchor=legend_anchor)

for i in range(2):
    for j in range(2):
        axes[i,j].set_ylabel('Proportion of simulations')


# starting_label_x = 0.1
# label_y = 0
# label_x_increment = 0.2025
# for i in range(4):
#     plt.gcf().text(starting_label_x+i*label_x_increment, label_y, \
#                    '(' + chr(ord('a')+i) + ')', fontsize=16)
# plt.subplots_adjust(wspace=0.2)
figure.tight_layout()
figure.subplots_adjust(wspace = .5, hspace = .7)
figure.show()

save_date_prefix = "190617"

figure.savefig(outdir_prefix+save_date_prefix+'HistogramConditionDiff.pdf', bbox_inches='tight')
normalNonZeroES = pd.read_csv('/Users//banditalgorithms/data/normalNonZeroESPriorChanges24April2018ProbArmsDiffer.csv')
largeEffectUniformSampling = get_subset_of_df(normalNonZeroES, 52, 'priorBetween', 'uniform')
largeEffectBanditSampling = get_subset_of_df(normalNonZeroES, 52, '0', 'bandit')
normalZeroES = pd.read_csv('/Users//banditalgorithms/data/normalZeroESPriorChanges24April2018ProbArmsDiffer.csv')
noEffectUniformSampling = get_subset_of_df(normalZeroES, 52, 'priorBetween', 'uniform', 1.25)
noEffectBanditSampling = get_subset_of_df(normalZeroES, 52, 'priorBetween', 'bandit', 1.25)


print(largeEffectBanditSampling.shape)
weights = np.ones_like(noEffectUniformSampling.avg_difference)/float(noEffectUniformSampling.shape[0])

bins = np.linspace(0, 1, 101)
figure, axes = plt.subplots(1, 4, figsize = (20,4))
bins = np.linspace(-3, 3, 101)
axes[0].hist(largeEffectUniformSampling.loc[:,'avg_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[0].hist(largeEffectBanditSampling.loc[:,'avg_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[0].set_title('Expected Difference\n(True difference = 1)')
axes[0].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[0].set_xticks(range(-2,3,1))
bins = np.linspace(-3, 3, 101)
axes[1].hist(largeEffectUniformSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[1].hist(largeEffectBanditSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[1].set_title('Expected Difference\n(True difference = 1)')
axes[1].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[1].set_xticks(range(-2,3,1))


bins = np.linspace(-2.5, 2.5, 101)
axes[2].hist(noEffectUniformSampling.loc[:,'avg_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[2].hist(noEffectBanditSampling.loc[:,'avg_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[2].set_title('Expected Difference\n(True difference = 0)')
axes[2].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[2].set_xticks(range(-2,3,1))

bins = np.linspace(-2.5, 2.5, 101)
axes[3].hist(noEffectUniformSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[3].hist(noEffectBanditSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[3].set_title('Expected Difference\n(True difference = 0)')
axes[3].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[3].set_xticks(range(-2,3,1))

legend_anchor=(1.3, 1.45)
axes[0].legend(ncol=2, bbox_to_anchor=legend_anchor)

starting_label_x = 0.1
label_y = 0
label_x_increment = 0.2025
for i in range(4):
    plt.gcf().text(starting_label_x+i*label_x_increment, label_y, \
                   '(' + chr(ord('a')+i) + ')', fontsize=16)
plt.subplots_adjust(wspace=0.2)
figure.savefig(outdir_prefix+date_prefix+'HistogramConditionDiff.pdf', bbox_inches='tight')
normalNonZeroES = pd.read_csv('/Users//banditalgorithms/data/normalNonZeroESPriorChanges24April2018ProbArmsDiffer.csv')
largeEffectUniformSampling = get_subset_of_df(normalNonZeroES, 52, 'priorBetween', 'uniform')
largeEffectBanditSampling = get_subset_of_df(normalNonZeroES, 52, '0', 'bandit')
normalZeroES = pd.read_csv('/Users//banditalgorithms/data/normalZeroESPriorChanges24April2018ProbArmsDiffer.csv')
noEffectUniformSampling = get_subset_of_df(normalZeroES, 52, 'priorBetween', 'uniform', 1.25)
noEffectBanditSampling = get_subset_of_df(normalZeroES, 52, 'priorBetween', 'bandit', 1.25)


print(largeEffectBanditSampling.shape)
weights = np.ones_like(noEffectUniformSampling.avg_difference)/float(noEffectUniformSampling.shape[0])

bins = np.linspace(0, 1, 101)
figure, axes = plt.subplots(1, 4, figsize = (20,4))
bins = np.linspace(-3, 3, 101)
axes[0].hist(largeEffectUniformSampling.loc[:,'avg_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[0].hist(largeEffectBanditSampling.loc[:,'avg_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[0].set_title('Expected Difference\n(True difference = 1)')
axes[0].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[0].set_xticks(range(-2,3,1))
bins = np.linspace(-3, 3, 101)
axes[1].hist(largeEffectUniformSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[1].hist(largeEffectBanditSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[1].set_title('Expected Difference\n(True difference = 1)')
axes[1].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[1].set_xticks(range(-2,3,1))


bins = np.linspace(-2.5, 2.5, 101)
axes[2].hist(noEffectUniformSampling.loc[:,'avg_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[2].hist(noEffectBanditSampling.loc[:,'avg_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[2].set_title('Expected Difference\n(True difference = 0)')
axes[2].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[2].set_xticks(range(-2,3,1))

bins = np.linspace(-2.5, 2.5, 101)
axes[3].hist(noEffectUniformSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[-1],label='Uniform assignment', weights=weights)
axes[3].hist(noEffectBanditSampling.loc[:,'exp_value_difference'], bins, alpha=0.6, color = colors[1],label='MAB assignment', weights=weights)
axes[3].set_title('Expected Difference\n(True difference = 0)')
axes[3].set_xlabel('E[Cond. 1 - Cond. 2]')
axes[3].set_xticks(range(-2,3,1))

legend_anchor=(1.3, 1.45)
axes[0].legend(ncol=2, bbox_to_anchor=legend_anchor)

starting_label_x = 0.1
label_y = 0
label_x_increment = 0.2025
for i in range(4):
    plt.gcf().text(starting_label_x+i*label_x_increment, label_y, \
                   '(' + chr(ord('a')+i) + ')', fontsize=16)
plt.subplots_adjust(wspace=0.2)
figure.savefig(outdir_prefix+date_prefix+'HistogramConditionDiff.pdf', bbox_inches='tight')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17212496226984605, 'fraction_numerical': 0.04738907334741926, 'mean_word_length': 7.707621550591327, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '207170', 'license': 'Apache-2.0', 'n_tokens_mistral': 5306, 'n_tokens_neox': 4806, 'n_words': 744, 'path': 'PostDiffMixture/simulations_folder/simulation_analysis_saves/banditsGraphs/Histograms of Sample Sizes.ipynb', 'repo_name': 'SIGKDDanon/SIGKDD2021DeAnonV2', 'size': '13252'}