def likelihood_calc(mu_emg,sigma_emg,lamb_emg,mu_norm,cov_norm,pi,X): value = logp_emg_np(X[:,0], mu_emg, sigma_emg,lamb_emg) value += np.array([mvNormal_logp_np(X[i,1:], mu_norm, cov_norm)[0] for i in np.arange(X.shape[0])]) return pi*np.exp(value)
lamb = tr["lamb_emg"][link,label] pi = tr["p"][link,label] #### data_label = np.zeros((50,50,50,50)) for dim in np.arange(4): reshape_dim = np.ones(4) reshape_dim[dim] = 50 tile_dim = np.ones(4,int)*50 tile_dim[dim] = 1 tile_dim = tuple(tile_dim) if dim ==0: value = logp_emg_np(all_range[dim], mu[dim], sigma[dim],lamb) else: value = logp_norm_np(all_range[dim], mu[dim], sigma[dim]) data_label+= np.tile(value.reshape(*reshape_dim),tile_dim) hold_data_inner += pi*np.exp(data_label) hold_data += hold_data_inner print(str(element)+":",np.round((link+count_less)/total,3), np.round(time.time()-start_time)) pickle.dump( hold_data, open(data_weight+"ideogram_4d_weighted_new_"+\ str(element) +".pkl", "wb" ) )
for dim_select in np.arange(5)+1: xx = np.linspace(np.min(data[:,0]),np.max(data[:,0]),50) yy = np.linspace(np.min(data[:,dim_select]),np.max(data[:,dim_select]),50) mu_emg = group_dict["mu_emg"] mu_norm = group_dict["mu_norm"][dim_select-1] sigma_emg = group_dict["sigma_emg"] sigma_norm = group_dict["sigma_norm"][dim_select-1] lamb_emg = group_dict["lamb_emg"] contour_data = np.zeros((xx.shape[0],yy.shape[0])) for i,j in itertools.product(np.arange(xx.shape[0]), np.arange(yy.shape[0])): contour_data[i,j] = logp_emg_np(xx[i],mu_emg,sigma_emg,lamb_emg)+\ logp_norm_np(yy[j],mu_norm,sigma_norm) emg_norm_2d_smart_plot([ax[dim_select,0]], [contour_data.T],xx,yy,num_lines=5,colour = "blue") fig.tight_layout() plt.savefig(LKJ_images_location+"pairs_plotting_largest_class_cat_colour.png") plt.close() group_num = 1 fig, ax =high_d_plot(data,colours = cat_like,dimension=(),alpha = .3) group_dict = all_info[group_num] norm_squared_contour_2d_smart_plot(ax[1:,1:],mu = group_dict["mu_norm"],