def main(d_obs, run, rep, alpha, sample_size_obs, n_sampled_true_tau, debug=False, seed=7, verbose=False, marginal=False, size_marginal=1000, size_check=10000):
    rep = (rep if (not debug) else 2)
    n_sampled_true_tau = (n_sampled_true_tau if (not debug) else 10)
    model_obj = model_dict[run](d_obs=d_obs, marginal=marginal, size_marginal=size_marginal)
    grid_param = model_obj.grid
    gen_obs_func = model_obj.sample_sim
    gen_sample_func = model_obj.generate_sample
    or_func = model_obj.compute_exact_or
    t0_grid = model_obj.pred_grid
    tp_func = model_obj.compute_exact_prob
    t0_val = model_obj.true_param
    np.random.seed(seed)
    out_val = []
    out_cols = ['d_obs', 'run', 'rep', 'classifier', 'sample_size_obs', 't0_true_val', 'theta_0_current', 'on_true_t0', 'in_true_interval', 'size_true_int', 'true_entropy']
    pbar = tqdm(total=rep, desc=('Toy Example for Simulations, n=%s' % sample_size_obs))
    for jj in range(rep):
        sample_check = gen_sample_func(sample_size=size_check, marginal=False)
        theta_vec = sample_check[:, :model_obj.d]
        x_vec = sample_check[:, (model_obj.d + 1):]
        bern_vec = sample_check[:, model_obj.d]
        true_prob_vec = tp_func(theta_vec=theta_vec, x_vec=x_vec)
        entropy_est = (- np.average([(np.log(true_prob_vec[kk]) if (el == 1) else np.log((1 - true_prob_vec[kk]))) for (kk, el) in enumerate(bern_vec)]))
        x_obs = gen_obs_func(sample_size=sample_size_obs, true_param=t0_val)
        tau_obs = np.array([compute_exact_tau(or_func=or_func, x_obs=x_obs, t0_val=theta_0, t1_linspace=grid_param) for theta_0 in t0_grid])
        tau_distr = np.apply_along_axis(arr=t0_grid.reshape((- 1), model_obj.d), axis=1, func1d=(lambda t0: compute_exact_tau_distr(gen_obs_func=gen_obs_func, or_func=or_func, t0_val=t0, t1_linspace=grid_param, n_sampled=n_sampled_true_tau, sample_size_obs=sample_size_obs, d_obs=model_obj.d_obs)))
        assert (tau_distr.shape == (t0_grid.shape[0], n_sampled_true_tau))
        quantile_pred_tau = np.quantile(a=tau_distr, q=alpha, axis=1)
        true_interval = (tau_obs > quantile_pred_tau).astype(int)
        true_interval_size = (np.sum(true_interval) / true_interval.shape[0])
        for (kk, theta_0_current) in enumerate(t0_grid):
            out_val.append([d_obs, run, jj, 'Exact', sample_size_obs, t0_val, theta_0_current, int((t0_val == theta_0_current)), true_interval[kk], true_interval_size, entropy_est])
        pbar.update(1)
    out_df = pd.DataFrame.from_records(data=out_val, index=range(len(out_val)), columns=out_cols)
    out_dir = 'sims/classifier_power_multid/'
    out_filename = ('truth_classifier_power_multid%s_%s_%srep_alpha%s_sampleobs%s_t0val%s_%ssampletau_%s.csv' % (d_obs, run, rep, str(alpha).replace('.', '-'), sample_size_obs, str(t0_val).replace('.', '-'), n_sampled_true_tau, datetime.strftime(datetime.today(), '%Y-%m-%d')))
    out_df.to_csv((out_dir + out_filename))
    cov_df = out_df[(out_df['on_true_t0'] == 1)][['classifier', 'in_true_interval', 'true_entropy', 'size_true_int']]
    print(cov_df.groupby(['classifier']).agg({'in_true_interval': [np.average], 'size_true_int': [np.average, np.std], 'true_entropy': [np.average, np.std]}))
def main(d_obs, run, rep, alpha, sample_size_obs, n_sampled_true_tau, debug=False, seed=7, verbose=False, marginal=False, size_marginal=1000, size_check=10000):
    rep = (rep if (not debug) else 2)
    n_sampled_true_tau = (n_sampled_true_tau if (not debug) else 10)
    model_obj = model_dict[run](d_obs=d_obs, marginal=marginal, size_marginal=size_marginal)
    grid_param = model_obj.grid
    gen_obs_func = model_obj.sample_sim
    gen_sample_func = model_obj.generate_sample
    or_func = model_obj.compute_exact_or
    t0_grid = model_obj.pred_grid
    tp_func = model_obj.compute_exact_prob
    t0_val = model_obj.true_param
    np.random.seed(seed)
    out_val = []
    out_cols = ['d_obs', 'run', 'rep', 'classifier', 'sample_size_obs', 't0_true_val', 'theta_0_current', 'on_true_t0', 'in_true_interval', 'size_true_int', 'true_entropy']
    pbar = tqdm(total=rep, desc=('Toy Example for Simulations, n=%s' % sample_size_obs))
    for jj in range(rep):
        sample_check = gen_sample_func(sample_size=size_check, marginal=False)
        theta_vec = sample_check[:, :model_obj.d]
        x_vec = sample_check[:, (model_obj.d + 1):]
        bern_vec = sample_check[:, model_obj.d]
        true_prob_vec = tp_func(theta_vec=theta_vec, x_vec=x_vec)
        entropy_est = (- np.average([(np.log(true_prob_vec[kk]) if (el == 1) else np.log((1 - true_prob_vec[kk]))) for (kk, el) in enumerate(bern_vec)]))
        x_obs = gen_obs_func(sample_size=sample_size_obs, true_param=t0_val)
        tau_obs = np.array([compute_exact_tau(or_func=or_func, x_obs=x_obs, t0_val=theta_0, t1_linspace=grid_param) for theta_0 in t0_grid])
        tau_distr = np.apply_along_axis(arr=t0_grid.reshape((- 1), model_obj.d), axis=1, func1d=(lambda t0: compute_exact_tau_distr(gen_obs_func=gen_obs_func, or_func=or_func, t0_val=t0, t1_linspace=grid_param, n_sampled=n_sampled_true_tau, sample_size_obs=sample_size_obs, d_obs=model_obj.d_obs)))
        assert (tau_distr.shape == (t0_grid.shape[0], n_sampled_true_tau))
        quantile_pred_tau = np.quantile(a=tau_distr, q=alpha, axis=1)
        true_interval = (tau_obs > quantile_pred_tau).astype(int)
        true_interval_size = (np.sum(true_interval) / true_interval.shape[0])
        for (kk, theta_0_current) in enumerate(t0_grid):
            out_val.append([d_obs, run, jj, 'Exact', sample_size_obs, t0_val, theta_0_current, int((t0_val == theta_0_current)), true_interval[kk], true_interval_size, entropy_est])
        pbar.update(1)
    out_df = pd.DataFrame.from_records(data=out_val, index=range(len(out_val)), columns=out_cols)
    out_dir = 'sims/classifier_power_multid/'
    out_filename = ('truth_classifier_power_multid%s_%s_%srep_alpha%s_sampleobs%s_t0val%s_%ssampletau_%s.csv' % (d_obs, run, rep, str(alpha).replace('.', '-'), sample_size_obs, str(t0_val).replace('.', '-'), n_sampled_true_tau, datetime.strftime(datetime.today(), '%Y-%m-%d')))
    out_df.to_csv((out_dir + out_filename))
    cov_df = out_df[(out_df['on_true_t0'] == 1)][['classifier', 'in_true_interval', 'true_entropy', 'size_true_int']]
    print(cov_df.groupby(['classifier']).agg({'in_true_interval': [np.average], 'size_true_int': [np.average, np.std], 'true_entropy': [np.average, np.std]}))