#!/usr/bin/env python # coding: utf-8 # In[1]: from mpl_toolkits import mplot3d import pandas as pd import numpy as np import numpy.random import matplotlib.pyplot as plt import pickle from math import gamma """self_norm_sum, self_norm_sum_ast, beta_n, sigma_n, alpha_n, rho_n, max_p(sn_2), min_p(sn_2), beta""" import time import concurrent.futures import random import os from scipy.linalg import toeplitz # to generate toeplitz matrix def cov_toep(s, q): """A function that takes the dependency thresholds $s$ and the dimension $q$ and returns a qxq-toeplitz matrix. """ row = np.array([]) for k in range(q): row = np.append(row, float(s**k)) return toeplitz(row, row) def scalar(A,B): """Takes two symmetric matrices A and B of sizes q and returns the modified frobenius scalar of A and B """ return(np.trace(A.dot(np.transpose(B)))/A.shape[0]) def norm(A): """Takes a symmetric matrix A of sizes q and returns the norm of A This norm is associated to the modified frobenius scalar """ return np.sqrt(scalar(A,A)) def max_p(M): """Largest eigenvalue of a given matrix M""" val_p = np.linalg.eigvals(M) return max(val_p.real) def min_p(M): """Smallest eigenvalue of a given matrix M that is not null""" val_p = np.linalg.eigvals(M) val_p = val_p[val_p>=10**-6] return min(val_p.real) def alphaaa1(S_2): q = len(S_2) I_q = np.diag(np.ones(q)) sigma2 = scalar(S_2,I_q) alpha2 = norm(S_2 - sigma2*I_q)**2 return alpha2 def alphaaa2(vec): q = len(vec) I_q = np.diag(np.ones(q)) S_2 = np.diag(vec) sigma2 = scalar(S_2,I_q) alpha2 = norm(S_2 - sigma2*I_q)**2 return alpha2 q_list = list(pickle.load(open("q_list", "rb"))) n_list = list(pickle.load(open("n_list", "rb"))) #def bounding(n, t): # return (2*np.exp(3)/9)*((t-n)/2)**(n/2)*np.exp(-(t-n)/2)/gamma((n/2)+1) #bnd_dict = {} #for n in n_list: # bnd_dict[n] = lambda x : bounding(n, x) # # 0. **self_norm_sum** (combined version) # 1. **self_norm_sum_ast** (penalized version) # 2. **beta_n** # 3. **sigma_n** # 4. **alpha_n** # 5. **rho_n** # 6. **norm1(vp)**\* # 7. **norm2(vp)** # 8. **norm3(vp)** # 9. **beta** # # \*$ vp =\textrm{valeur prope} = \frac{\lambda_j}{\hat{\rho}_n^{\ast} + \lambda_j} $ # In[2]: #vp_i_d06 = pickle.load(open("vp_collection_d06", "rb")) #vp_i_d099 = pickle.load(open("vp_collection_d099", "rb")) #vp_i_d0999999 = pickle.load(open("vp_collection_d0999999", "rb")) data_i_d06 = pickle.load(open("independent_(d06)", "rb")) data_i_d099 = pickle.load(open("independent_(d099)", "rb")) #data_i_d0999999 = pickle.load(open("data_vp_collection_d0999999", "rb")) #data_id = pickle.load(open("data_vp_collection_id", "rb")) data_d06 = pickle.load(open("dependent_(d06)", "rb")) data_d099 = pickle.load(open("dependent_(d099)", "rb")) #data_d0999999 = pickle.load(open("data_d_s0.999999", "rb")) # # 0. **self_norm_sum** (combined version) # 1. **self_norm_sum_ast** (penalized version) # 2. **beta_n** # 3. **sigma_n** # 4. **alpha_n** # 5. **rho_n** # 6. **max_p(sn_2)** # 7. **min_p(sn_2)** # 8. **beta** # In[3]: list(data_i_d06.keys())[3] # In[3]: get_ipython().run_line_magic('matplotlib', 'notebook') # In[19]: xmin = 0 ; xmax = 16 plt.hist(data_i_d06[list(data_i_d06.keys())[0]][:,5], bins=45, label="q=50", range=[xmin,xmax]) plt.axvline(np.mean(data_i_d06[list(data_i_d06.keys())[0]][:,5]), color="darkblue", alpha=1, label="mean", linewidth=2) plt.hist(data_i_d06[list(data_i_d06.keys())[3]][:,5], bins=45, label="q=200", range=[xmin,xmax]) plt.axvline(np.mean(data_i_d06[list(data_i_d06.keys())[3]][:,5]), alpha=1, color="orangered", linewidth=2) plt.hist(data_i_d06[list(data_i_d06.keys())[7]][:,5], bins=45, label="q=400", range=[xmin,xmax]) plt.axvline(np.mean(data_i_d06[list(data_i_d06.keys())[7]][:,5]), color="darkgreen", alpha=1, linewidth=2) # plt.legend(loc="upper right") plt.legend(loc="upper right", facecolor='white', framealpha=0) # plt.title("rho* - independent case, n=50") plt.xticks(list(plt.xticks()[0])[:1]+[round(np.mean(data_i_d06[list(data_i_d06.keys())[0]][:,5]),3)]+list(plt.xticks()[0])[2:]) plt.show() # In[103]: list(data_i_d06.keys()).index((100,400)) # ## Rho - s0.6 - independent vs dependent # In[ ]: # In[22]: get_ipython().run_line_magic('matplotlib', 'notebook') fig, axs = plt.subplots(3, 2, constrained_layout=True, figsize=(9, 9)) axs = axs.ravel() # plt.figsize(10, 7) axs[0].hist(data_i_d06[list(data_i_d06.keys())[0]][:,5], bins=45, label="q=50", color="orange") axs[0].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[0]][:,5]), color="orangered", alpha=1, linewidth=1.75) axs[0].hist(data_i_d06[list(data_i_d06.keys())[3]][:,5], bins=45, label="q=200", color="blue") axs[0].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[3]][:,5]), alpha=1, color="darkblue", linewidth=1.75) axs[0].hist(data_i_d06[list(data_i_d06.keys())[7]][:,5], bins=45, label="q=400", color="green") axs[0].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[7]][:,5]), color="darkgreen", alpha=1, linewidth=1.75) axs[0].set_ylabel('n = 50', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) axs[0].set_title('Independent case', style="italic", fontsize=14) #axs[0].legend(loc="upper right") axs[2].hist(data_i_d06[list(data_i_d06.keys())[0]][:,5], bins=45, label="q=50", color="orange") axs[2].hist(data_i_d06[list(data_i_d06.keys())[15]][:,5], bins=45, label="q=100", color='tomato') axs[2].hist(data_i_d06[list(data_i_d06.keys())[39]][:,5], bins=45, label="q=200", color="blue") axs[2].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[0]][:,5]), color="orangered", alpha=1, linewidth=1.75) axs[2].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[15]][:,5]), color="crimson", alpha=1, linewidth=1.75) axs[2].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[39]][:,5]), color="darkblue", alpha=1, linewidth=1.75) axs[2].set_ylabel('n = q', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) #axs[2].legend(loc="upper right") axs[4].hist(data_i_d06[list(data_i_d06.keys())[1]][:,5], bins=45, label="q=100", color='tomato') axs[4].hist(data_i_d06[list(data_i_d06.keys())[17]][:,5], bins=45, label="q=200", color="blue") axs[4].hist(data_i_d06[list(data_i_d06.keys())[31]][:,5], bins=45, label="q=300", color="gold") axs[4].hist(data_i_d06[list(data_i_d06.keys())[43]][:,5], bins=45, label="q=400", color="green") axs[4].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[1]][:,5]), color="red", alpha=1, linewidth=1.75) axs[4].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[31]][:,5])+.01, color="darkorange", alpha=1, linewidth=1.75) axs[4].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[17]][:,5])-.01, color="darkblue", alpha=.9, linewidth=1.75) axs[4].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[43]][:,5]), color="darkgreen", alpha=1, linewidth=1.75) axs[4].set_ylabel('n = q/2', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) #axs[4].legend(loc="upper right") axs[1].hist(data_d06[list(data_d06.keys())[0]][:,5], bins=45, label="q=50", color="orange") axs[1].hist(data_d06[list(data_d06.keys())[3]][:,5], bins=45, label="q=200", color="blue") axs[1].hist(data_d06[list(data_d06.keys())[7]][:,5], bins=45, label="q=400", color="green") axs[1].axvline(np.mean(data_d06[list(data_d06.keys())[0]][:,5]), color="orangered", alpha=1, linewidth=1.75) axs[1].axvline(np.mean(data_d06[list(data_d06.keys())[3]][:,5]), color="darkblue", alpha=1, linewidth=1.75) axs[1].axvline(np.mean(data_d06[list(data_d06.keys())[7]][:,5]), color="darkgreen", alpha=1, linewidth=1.75) axs[1].legend(loc="upper right", facecolor='white', framealpha=0) axs[1].set_title('Dependent case (s=0.6)', style="italic", fontsize=14) axs[3].hist(data_d06[list(data_d06.keys())[0]][:,5], bins=45, label="q=50", color="orange") axs[3].hist(data_d06[list(data_d06.keys())[15]][:,5], bins=45, label="q=100", color='tomato') axs[3].hist(data_d06[list(data_d06.keys())[39]][:,5], bins=45, label="q=200", color="blue") axs[3].axvline(np.mean(data_d06[list(data_d06.keys())[0]][:,5]), color="orangered", alpha=1, linewidth=1.75) axs[3].axvline(np.mean(data_d06[list(data_d06.keys())[15]][:,5]), color="crimson", alpha=1, linewidth=1.75) axs[3].axvline(np.mean(data_d06[list(data_d06.keys())[39]][:,5])-.0001, color="darkblue", alpha=1, linewidth=1.75) axs[3].legend(loc="upper right", facecolor='white', framealpha=0) axs[5].hist(data_d06[list(data_d06.keys())[1]][:,5], bins=45, label="q=100", color='tomato') axs[5].hist(data_d06[list(data_d06.keys())[17]][:,5], bins=45, label="q=200", color="blue") axs[5].hist(data_d06[list(data_d06.keys())[31]][:,5], bins=45, label="q=300", color="gold") axs[5].hist(data_d06[list(data_d06.keys())[43]][:,5], bins=45, label="q=400", color="green") axs[5].axvline(np.mean(data_d06[list(data_d06.keys())[1]][:,5]), color="crimson", alpha=1, linewidth=1.75) axs[5].axvline(np.mean(data_d06[list(data_d06.keys())[17]][:,5]), color="darkblue", alpha=.9, linewidth=1.75) axs[5].axvline(np.mean(data_d06[list(data_d06.keys())[31]][:,5]), color="darkorange", alpha=1, linewidth=1.75) axs[5].axvline(np.mean(data_d06[list(data_d06.keys())[43]][:,5])+.005, color="darkgreen", alpha=1, linewidth=1.75) axs[5].legend(loc="upper right", facecolor='white', framealpha=0) #plt.title("rho = dependent case, s=0.6, n=2q") #handles, labels = axs.get_legend_handles_labels() #fig.legend(handles, labels, loc='upper center') plt.show() # ## Rho - s0.99 - independent vs dependent # In[23]: get_ipython().run_line_magic('matplotlib', 'notebook') fig, axs = plt.subplots(3, 2, constrained_layout=True, figsize=(9, 9)) axs = axs.ravel() # plt.rcParams['figure.figsize'] = [10, 7] axs[0].hist(data_i_d099[list(data_i_d099.keys())[0]][:,5], bins=45, label="q=50", color="orange") axs[0].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[0]][:,5]), color="orangered", alpha=1, linewidth=1.75) axs[0].hist(data_i_d099[list(data_i_d099.keys())[3]][:,5], bins=45, label="q=200", color="blue") axs[0].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[3]][:,5]), alpha=1, color="darkblue", linewidth=1.75) axs[0].hist(data_i_d099[list(data_i_d099.keys())[7]][:,5], bins=45, label="q=400", color="green") axs[0].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[7]][:,5]), color="darkgreen", alpha=1, linewidth=1.75) axs[0].set_ylabel('n = 50', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) axs[0].set_title('Independent case', style="italic", fontsize=14) #axs[0].legend(loc="upper right") axs[2].hist(data_i_d099[list(data_i_d099.keys())[0]][:,5], bins=45, label="q=50", color="orange") axs[2].hist(data_i_d099[list(data_i_d099.keys())[15]][:,5], bins=45, label="q=100", color='tomato') axs[2].hist(data_i_d099[list(data_i_d099.keys())[39]][:,5], bins=45, label="q=200", color="blue") axs[2].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[0]][:,5]), color="orangered", alpha=1, linewidth=1.75) axs[2].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[15]][:,5]), color="crimson", alpha=1, linewidth=1.75) axs[2].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[39]][:,5]), color="darkblue", alpha=1, linewidth=1.75) axs[2].set_ylabel('n = q', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) #axs[2].legend(loc="upper right") axs[4].hist(data_i_d099[list(data_i_d099.keys())[1]][:,5], bins=45, label="q=100", color='tomato') axs[4].hist(data_i_d099[list(data_i_d099.keys())[17]][:,5], bins=45, label="q=200", color="blue") axs[4].hist(data_i_d099[list(data_i_d099.keys())[31]][:,5], bins=45, label="q=300", color="gold") axs[4].hist(data_i_d099[list(data_i_d099.keys())[43]][:,5], bins=45, label="q=400", color="green") axs[4].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[1]][:,5]), color="red", alpha=1, linewidth=1.75) axs[4].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[31]][:,5]), color="darkorange", alpha=1, linewidth=1.75) axs[4].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[17]][:,5]), color="darkblue", alpha=.9, linewidth=1.75) axs[4].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[43]][:,5]), color="darkgreen", alpha=1, linewidth=1.75) axs[4].set_ylabel('n = q/2', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) #axs[4].legend(loc="upper right") axs[1].hist(data_d099[list(data_d099.keys())[0]][:,5], bins=45, label="q=50", color="orange") axs[1].hist(data_d099[list(data_d099.keys())[3]][:,5], bins=45, label="q=200", color="blue") axs[1].hist(data_d099[list(data_d099.keys())[7]][:,5], bins=45, label="q=400", color="green") axs[1].axvline(np.mean(data_d099[list(data_d099.keys())[0]][:,5]), color="orangered", alpha=1, linewidth=1.75) axs[1].axvline(np.mean(data_d099[list(data_d099.keys())[3]][:,5]), color="darkblue", alpha=1, linewidth=1.75) axs[1].axvline(np.mean(data_d099[list(data_d099.keys())[7]][:,5]), color="darkgreen", alpha=1, linewidth=1.75) axs[1].legend(loc="upper right", facecolor='white', framealpha=0) axs[1].set_title('Dependent case (s=0.99)', style="italic", fontsize=14) axs[3].hist(data_d099[list(data_d099.keys())[0]][:,5], bins=45, label="q=50", color="orange") axs[3].hist(data_d099[list(data_d099.keys())[15]][:,5], bins=45, label="q=100", color='tomato') axs[3].hist(data_d099[list(data_d099.keys())[39]][:,5], bins=45, label="q=200", color="blue") axs[3].axvline(np.mean(data_d099[list(data_d099.keys())[0]][:,5]), color="orangered", alpha=1, linewidth=1.75) axs[3].axvline(np.mean(data_d099[list(data_d099.keys())[15]][:,5]), color="crimson", alpha=1, linewidth=1.75) axs[3].axvline(np.mean(data_d099[list(data_d099.keys())[39]][:,5]), color="darkblue", alpha=1, linewidth=1.75) axs[3].legend(loc="upper right", facecolor='white', framealpha=0) axs[5].hist(data_d099[list(data_d099.keys())[1]][:,5], bins=45, label="q=100", color='tomato') axs[5].hist(data_d099[list(data_d099.keys())[17]][:,5], bins=45, label="q=200", color="blue") axs[5].hist(data_d099[list(data_d099.keys())[31]][:,5], bins=45, label="q=300", color="gold") axs[5].hist(data_d099[list(data_d099.keys())[43]][:,5], bins=45, label="q=400", color="green") axs[5].axvline(np.mean(data_d099[list(data_d099.keys())[1]][:,5]), color="crimson", alpha=1, linewidth=1.75) axs[5].axvline(np.mean(data_d099[list(data_d099.keys())[17]][:,5]), color="darkblue", alpha=.9, linewidth=1.75) axs[5].axvline(np.mean(data_d099[list(data_d099.keys())[31]][:,5]), color="darkorange", alpha=1, linewidth=1.75) axs[5].axvline(np.mean(data_d099[list(data_d099.keys())[43]][:,5]), color="darkgreen", alpha=1, linewidth=1.75) axs[5].legend(loc="upper right", facecolor='white', framealpha=0) #plt.title("rho = dependent case, s=0.6, n=2q") #handles, labels = axs.get_legend_handles_labels() #fig.legend(handles, labels, loc='upper center') plt.show() # ## Sns - s0.6 - independent vs dependent # In[26]: xmin_i = min([min(data_i_d06[list(data_i_d06.keys())[k]][:,1]) for k in [0,3,7,15,39,1,17,31,39,43]]) xmin_d = min([min(data_d06[list(data_d06.keys())[k]][:,1]) for k in [0,3,7,15,39,1,17,31,39,43]]) xmax_i = max([max(data_i_d06[list(data_i_d06.keys())[k]][:,1]) for k in [0,3,7,15,39,1,17,31,39,43]]) xmax_d = max([max(data_d06[list(data_d06.keys())[k]][:,1]) for k in [0,3,7,15,39,1,17,31,39,43]]) xmin, xmax = min(xmin_i, xmin_d), max(xmax_i, xmax_d) ; limits = [xmin, xmax] print(limits) # In[27]: ymax = 360 get_ipython().run_line_magic('matplotlib', 'notebook') fig, axs = plt.subplots(3, 2, constrained_layout=True, figsize=(9, 9)) axs = axs.ravel() axs[0].hist(data_i_d06[list(data_i_d06.keys())[0]][:,1], bins=45, label="q=50", color="orange", range=[xmin,xmax]) axs[0].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[0]][:,1]), color="orangered", alpha=1, linewidth=1.75) axs[0].hist(data_i_d06[list(data_i_d06.keys())[3]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[0].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[3]][:,1]), alpha=1, color="darkblue", linewidth=1.75) axs[0].hist(data_i_d06[list(data_i_d06.keys())[7]][:,1], bins=45, label="q=400", color="green", range=[xmin,xmax]) axs[0].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[7]][:,1]), color="darkgreen", alpha=1, linewidth=1.75) axs[0].set_ylim(top=ymax, bottom=0) axs[0].set_ylabel('n = 50', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) axs[0].set_title('Independent case', style="italic", fontsize=14) #axs[0].legend(loc="upper right") axs[2].hist(data_i_d06[list(data_i_d06.keys())[0]][:,1], bins=45, label="q=50", color="orange", range=[xmin,xmax]) axs[2].hist(data_i_d06[list(data_i_d06.keys())[15]][:,1], bins=45, label="q=100", color='tomato', range=[xmin,xmax]) axs[2].hist(data_i_d06[list(data_i_d06.keys())[39]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[2].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[0]][:,1]), color="orangered", alpha=1, linewidth=1.75) axs[2].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[15]][:,1]), color="crimson", alpha=1, linewidth=1.75) axs[2].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[39]][:,1]), color="darkblue", alpha=1, linewidth=1.75) axs[2].set_ylim(top=ymax, bottom=0) axs[2].set_ylabel('n = q', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) #axs[2].legend(loc="upper right") axs[4].hist(data_i_d06[list(data_i_d06.keys())[1]][:,1], bins=45, label="q=100", color='tomato', range=[xmin,xmax]) axs[4].hist(data_i_d06[list(data_i_d06.keys())[17]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[4].hist(data_i_d06[list(data_i_d06.keys())[31]][:,1], bins=45, label="q=300", color="gold", range=[xmin,xmax]) axs[4].hist(data_i_d06[list(data_i_d06.keys())[43]][:,1], bins=45, label="q=400", color="green", range=[xmin,xmax]) axs[4].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[1]][:,1]), color="red", alpha=1, linewidth=1.75) axs[4].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[31]][:,1]), color="darkorange", alpha=1, linewidth=1.75) axs[4].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[17]][:,1]), color="darkblue", alpha=.9, linewidth=1.75) axs[4].axvline(np.mean(data_i_d06[list(data_i_d06.keys())[43]][:,1]), color="darkgreen", alpha=1, linewidth=1.75) axs[4].set_ylim(top=ymax, bottom=0) axs[4].set_ylabel('n = q/2', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) #axs[4].legend(loc="upper right") axs[1].hist(data_d06[list(data_d06.keys())[0]][:,1], bins=45, label="q=50", color="orange", range=[xmin,xmax]) axs[1].hist(data_d06[list(data_d06.keys())[3]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[1].hist(data_d06[list(data_d06.keys())[7]][:,1], bins=45, label="q=400", color="green", range=[xmin,xmax]) axs[1].axvline(np.mean(data_d06[list(data_d06.keys())[0]][:,1]), color="orangered", alpha=1, linewidth=1.75) axs[1].axvline(np.mean(data_d06[list(data_d06.keys())[3]][:,1]), color="darkblue", alpha=1, linewidth=1.75) axs[1].axvline(np.mean(data_d06[list(data_d06.keys())[7]][:,1]), color="darkgreen", alpha=1, linewidth=1.75) axs[1].set_ylim(top=ymax, bottom=0) axs[1].legend(loc="upper right", facecolor='white', framealpha=0) axs[1].set_title('Dependent case (s=0.6)', style="italic", fontsize=14) axs[3].hist(data_d06[list(data_d06.keys())[0]][:,1], bins=45, label="q=50", color="orange", range=[xmin,xmax]) axs[3].hist(data_d06[list(data_d06.keys())[15]][:,1], bins=45, label="q=100", color='tomato', range=[xmin,xmax]) axs[3].hist(data_d06[list(data_d06.keys())[39]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[3].axvline(np.mean(data_d06[list(data_d06.keys())[0]][:,1]), color="orangered", alpha=1, linewidth=1.75) axs[3].axvline(np.mean(data_d06[list(data_d06.keys())[15]][:,1]), color="crimson", alpha=1, linewidth=1.75) axs[3].axvline(np.mean(data_d06[list(data_d06.keys())[39]][:,1]), color="darkblue", alpha=1, linewidth=1.75) axs[3].set_ylim(top=ymax, bottom=0) axs[3].legend(loc="upper right", facecolor='white', framealpha=0) axs[5].hist(data_d06[list(data_d06.keys())[1]][:,1], bins=45, label="q=100", color='tomato', range=[xmin,xmax]) axs[5].hist(data_d06[list(data_d06.keys())[17]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[5].hist(data_d06[list(data_d06.keys())[31]][:,1], bins=45, label="q=300", color="gold", range=[xmin,xmax]) axs[5].hist(data_d06[list(data_d06.keys())[43]][:,1], bins=45, label="q=400", color="green", range=[xmin,xmax]) axs[5].axvline(np.mean(data_d06[list(data_d06.keys())[1]][:,1]), color="crimson", alpha=1, linewidth=1.75) axs[5].axvline(np.mean(data_d06[list(data_d06.keys())[17]][:,1]), color="darkblue", alpha=.9, linewidth=1.75) axs[5].axvline(np.mean(data_d06[list(data_d06.keys())[31]][:,1]), color="darkorange", alpha=1, linewidth=1.75) axs[5].axvline(np.mean(data_d06[list(data_d06.keys())[43]][:,1]), color="darkgreen", alpha=1, linewidth=1.75) axs[5].set_ylim(top=ymax, bottom=0) axs[5].legend(loc="upper right", facecolor='white', framealpha=0) #plt.title("rho = dependent case, s=0.6, n=2q") #handles, labels = axs.get_legend_handles_labels() #fig.legend(handles, labels, loc='upper center') plt.show() # ## Sns - s0.99 - independent vs dependent # In[28]: xmin_i = min([min(data_i_d099[list(data_i_d099.keys())[k]][:,1]) for k in [0,3,7,15,39,1,17,31,39,43]]) xmin_d = min([min(data_d099[list(data_d099.keys())[k]][:,1]) for k in [0,3,7,15,39,1,17,31,39,43]]) xmax_i = max([max(data_i_d099[list(data_i_d099.keys())[k]][:,1]) for k in [0,3,7,15,39,1,17,31,39,43]]) xmax_d = max([max(data_d099[list(data_d099.keys())[k]][:,1]) for k in [0,3,7,15,39,1,17,31,39,43]]) xmin, xmax = min(xmin_i, xmin_d), max(xmax_i, xmax_d) ; limits = [xmin, xmax] print(limits) # In[29]: ymax = 350 get_ipython().run_line_magic('matplotlib', 'notebook') fig, axs = plt.subplots(3, 2, constrained_layout=True, figsize=(9, 9)) axs = axs.ravel() axs[0].hist(data_i_d099[list(data_i_d099.keys())[0]][:,1], bins=45, label="q=50", color="orange", range=[xmin,xmax]) axs[0].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[0]][:,1]), color="orangered", alpha=1, linewidth=1.75) axs[0].hist(data_i_d099[list(data_i_d099.keys())[3]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[0].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[3]][:,1]), alpha=1, color="darkblue", linewidth=1.75) axs[0].hist(data_i_d099[list(data_i_d099.keys())[7]][:,1], bins=45, label="q=400", color="green", range=[xmin,xmax]) axs[0].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[7]][:,1]), color="darkgreen", alpha=1, linewidth=1.75) axs[0].set_ylim(top=ymax, bottom=0) axs[0].set_ylabel('n = 50', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) axs[0].set_title('Independent case', style="italic", fontsize=14) #axs[0].legend(loc="upper right") axs[2].hist(data_i_d099[list(data_i_d099.keys())[0]][:,1], bins=45, label="q=50", color="orange", range=[xmin,xmax]) axs[2].hist(data_i_d099[list(data_i_d099.keys())[15]][:,1], bins=45, label="q=100", color='tomato', range=[xmin,xmax]) axs[2].hist(data_i_d099[list(data_i_d099.keys())[39]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[2].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[0]][:,1]), color="orangered", alpha=1, linewidth=1.75) axs[2].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[15]][:,1]), color="crimson", alpha=1, linewidth=1.75) axs[2].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[39]][:,1]), color="darkblue", alpha=1, linewidth=1.75) axs[2].set_ylim(top=ymax, bottom=0) axs[2].set_ylabel('n = q', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) #axs[2].legend(loc="upper right") axs[4].hist(data_i_d099[list(data_i_d099.keys())[1]][:,1], bins=45, label="q=100", color='tomato', range=[xmin,xmax]) axs[4].hist(data_i_d099[list(data_i_d099.keys())[17]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[4].hist(data_i_d099[list(data_i_d099.keys())[31]][:,1], bins=45, label="q=300", color="gold", range=[xmin,xmax]) axs[4].hist(data_i_d099[list(data_i_d099.keys())[43]][:,1], bins=45, label="q=400", color="green", range=[xmin,xmax]) axs[4].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[1]][:,1]), color="red", alpha=1, linewidth=1.75) axs[4].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[31]][:,1]), color="darkorange", alpha=1, linewidth=1.75) axs[4].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[17]][:,1]), color="darkblue", alpha=.9, linewidth=1.75) axs[4].axvline(np.mean(data_i_d099[list(data_i_d099.keys())[43]][:,1]), color="darkgreen", alpha=1, linewidth=1.75) axs[4].set_ylim(top=ymax, bottom=0) axs[4].set_ylabel('n = q/2', rotation="horizontal", style="italic", fontsize=12.5, labelpad=25) #axs[4].legend(loc="upper right") axs[1].hist(data_d099[list(data_d099.keys())[0]][:,1], bins=45, label="q=50", color="orange", range=[xmin,xmax]) axs[1].hist(data_d099[list(data_d099.keys())[3]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[1].hist(data_d099[list(data_d099.keys())[7]][:,1], bins=45, label="q=400", color="green", range=[xmin,xmax]) axs[1].axvline(np.mean(data_d099[list(data_d099.keys())[0]][:,1]), color="orangered", alpha=1, linewidth=1.75) axs[1].axvline(np.mean(data_d099[list(data_d099.keys())[3]][:,1]), color="darkblue", alpha=1, linewidth=1.75) axs[1].axvline(np.mean(data_d099[list(data_d099.keys())[7]][:,1]), color="darkgreen", alpha=1, linewidth=1.75) axs[1].set_ylim(top=ymax, bottom=0) axs[1].legend(loc="upper right", facecolor='white', framealpha=0) axs[1].set_title('Dependent case (s=0.99)', style="italic", fontsize=14) axs[3].hist(data_d099[list(data_d099.keys())[0]][:,1], bins=45, label="q=50", color="orange", range=[xmin,xmax]) axs[3].hist(data_d099[list(data_d099.keys())[15]][:,1], bins=45, label="q=100", color='tomato', range=[xmin,xmax]) axs[3].hist(data_d099[list(data_d099.keys())[39]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[3].axvline(np.mean(data_d099[list(data_d099.keys())[0]][:,1]), color="orangered", alpha=1, linewidth=1.75) axs[3].axvline(np.mean(data_d099[list(data_d099.keys())[15]][:,1]), color="crimson", alpha=1, linewidth=1.75) axs[3].axvline(np.mean(data_d099[list(data_d099.keys())[39]][:,1]), color="darkblue", alpha=1, linewidth=1.75) axs[3].set_ylim(top=ymax, bottom=0) axs[3].legend(loc="upper right", facecolor='white', framealpha=0) axs[5].hist(data_d099[list(data_d099.keys())[1]][:,1], bins=45, label="q=100", color='tomato', range=[xmin,xmax]) axs[5].hist(data_d099[list(data_d099.keys())[17]][:,1], bins=45, label="q=200", color="blue", range=[xmin,xmax]) axs[5].hist(data_d099[list(data_d099.keys())[31]][:,1], bins=45, label="q=300", color="gold", range=[xmin,xmax]) axs[5].hist(data_d099[list(data_d099.keys())[43]][:,1], bins=45, label="q=400", color="green", range=[xmin,xmax]) axs[5].axvline(np.mean(data_d099[list(data_d099.keys())[1]][:,1]), color="crimson", alpha=1, linewidth=1.75) axs[5].axvline(np.mean(data_d099[list(data_d099.keys())[17]][:,1]), color="darkblue", alpha=.9, linewidth=1.75) axs[5].axvline(np.mean(data_d099[list(data_d099.keys())[31]][:,1]), color="darkorange", alpha=1, linewidth=1.75) axs[5].axvline(np.mean(data_d099[list(data_d099.keys())[43]][:,1]), color="darkgreen", alpha=1, linewidth=1.75) axs[5].set_ylim(top=ymax, bottom=0) axs[5].legend(loc="upper right", facecolor='white', framealpha=0) #plt.title("rho = dependent case, s=0.6, n=2q") #handles, labels = axs.get_legend_handles_labels() #fig.legend(handles, labels, loc='upper center') plt.show() # --- # --- #