def first_estimations(distributions, strats, cluster, cluster_index): """ """ epoch = 1 for s in strats: i = 0 while i < settings.N: #n, z = get_rand() n, z = launch_simulation_with_strategy(s, cluster) distributions[str(s[0])].get_posterior(n , z) plot.plot_distributions(distributions, cluster_index, epoch) i += 1 epoch += 1
def simulate_pairs(distributions, strats, cluster, cluster_index, d1, d2, epoch): """ """ r = 0 while r < settings.N: epoch += 1 s = strats[int(d1)] n, z = launch_simulation_with_strategy(s, cluster) distributions[d1].get_posterior(n , z) s = strats[int(d2)] n, z = launch_simulation_with_strategy(s, cluster) distributions[d2].get_posterior(n , z) plot.plot_distributions(distributions, cluster_index, epoch)
fig.savefig( os.path.join(fig_dir, 'new2_JSD_embedding_all_strains_tbins=%d.png' % (tbins))) #%% Plot Distributions and distances #for i, strain in enumerate(strains): for i, s0 in enumerate(strains): fig = plt.figure(300 + i, figsize=(21, 14)) plt.clf() ax = plt.subplot(3, 1, 1) rs = plt.cm.Reds(0.9) fplt.plot_distributions( dat_bin[s0], percentiles_colors=['black', rs, 'red', rs, 'black'], percentiles=[5, 25, 50, 75, 95], cmap=plt.cm.viridis) plt.xlim(0, tbins) plt.ylim(0, 1) plt.title('%s %s' % (s0, feat)) plt.subplot(3, 1, 2, sharex=ax) plt.plot(ent_t_g[s0]) plt.title('JS divergence to average distribution') plt.xlim(0, len(ent_t_g[s0])) plt.subplot(3, 1, 3, sharex=ax) plt.plot(ent_t_s_ref[s0]) plt.title('JS divergence to average stage distributions') plt.xlim(0, len(ent_t_g[s0])) plt.tight_layout()
z = random.randint(1, 20) return n, z #Global variables t_begin = time.time() storage = db.Database(settings.DATABASE) cluster_dict = storage.build_cluster_dictionnary() strats = storage.get_detailled_strategies() l_team = settings.TEAM_PATH + " " + settings.TEAM_PARAM #For each cluster for c in cluster_dict: write_log("cluster " + str(c) + ":\n") distributions = init_distributions(strats) plot.plot_distributions(distributions, 0, 0) cluster = cluster_dict[c] first_estimations(distributions, strats, cluster, c) strat_pairs = build_strategies_pairs(strats) strat_comparisons = init_strat_comparisons(strats) p = 0 #For each possible pair while p < len(strat_pairs): if len(strat_pairs) > 0: cp = strat_pairs[p] write_log("\tpair " + str(cp) + ":") d1 = distributions[str(cp[0])] d2 = distributions[str(cp[1])] write_log("[" + str(d1.n) + "," + str(d1.z) + "]-") write_log("[" + str(d2.n) + "," + str(d2.z) + "]--") conclusion = fe.formation_evaluator(d1.prior, d2.prior)
#!/usr/bin/env python3 #-*- coding: utf-8 -*- from scipy.stats import beta import numpy as np import corner_kick_distribution as ckd import formation_evaluator as fe import plot test = ckd.CK_Distribution() x = np.linspace(0, 1, 10000) p1 = test.get_posterior(40, 4) p2 = test.get_posterior(45, 3) p3 = test.get_posterior(36, 2) distributions = [p1, p2, p3] plot.plot_distributions(distributions)