clc %% theoretical distribution clear x a b z x = [0.001:0.001:1]; figure('units', 'normalized', 'outerposition', [-0.0046875 0.03796 1.009375 0.970]) % Uniform and bimodal sp_hand1 = subplot(1,3, 1); plot(x, x,'k', 'LineWidth', 3); hold on; grid on; b = x; b(b< .500) = 0; b(b> .499) = 1; plot(b, x,'Color',[0.47,0.67,0.19], 'LineWidth', 3); hold on; legend('Uniform', 'Bimodal'); set(legend,'Location','northwest','FontAngle','italic','FontSize',18); xlabel('x'); ylabel('F_X(x)'); set(gca,'FontName', 'DejaVuSans','FontSize',13 ); axis([-0.021 1.021 -.0021 1.01]); pos1 = get(sp_hand1, 'Position'); % gives the position of current sub-plot new_pos1 = pos1 +[-0.08 0 0.06 0.01]; set(sp_hand1, 'Position',new_pos1 ); % Gaussians sp_hand2 = subplot(1,3, 2); z = normcdf(x,0.5,0.2); plot(x, z,'Color',[0.30,0.75,0.93], 'LineWidth', 3); hold on; grid on; z = normcdf(x,0.5,0.08); plot(x, z,'Color',[0.00,0.45,0.74], 'LineWidth', 3); hold on; legend('Gaussian (\sigma_H)', 'Gaussian (\sigma_L)'); set(legend,'Location','northwest','FontAngle','italic','FontSize',18); xlabel('x'); ylabel('F_X(x)'); set(gca,'FontName', 'DejaVuSans','FontSize',13 ); axis([-0.021 1.021 -.0021 1.01]); pos2 = get(sp_hand2, 'Position'); % gives the position of current sub-plot new_pos2 = pos2 +[-0.03 0.0 0.06 0.01]; set(sp_hand2, 'Position',new_pos2 ); % Gamma sp_hand3 = subplot(1,3, 3); z = gamcdf(x,0.6,0.2); z(1,1)=0; plot(z, x,'Color', [0.93,0.69,0.13],'LineWidth', 3); hold on; grid on; x = [0.00001:0.00001:1]; z = gamrnd(2,2,[n*100,1]); z = z/(max(z)); z=sort(z,'ascend'); plot(z, x,'Color',[0.64,0.08,0.18], 'LineWidth', 3); hold on; legend('\Gamma^L', '\Gamma^R'); set(legend,'Location','northwest','FontAngle','italic','FontSize',18); xlabel('x'); ylabel('F_X(x)'); set(gca,'FontName', 'DejaVuSans','FontSize',13 ); axis([-0.021 1.021 -.0021 1.01]); pos3 = get(sp_hand3, 'Position'); % gives the position of current sub-plot new_pos3 = pos3 +[0.02 0.0 0.06 0.01]; set(sp_hand3, 'Position',new_pos3 ); %% final distributions ccc =1; cs = 1; figure('units', 'normalized', 'outerposition', [-0.0046875 0.03796 1.009375 0.970]) for cc = [2 5 8] %threshod %case pU aa = pU_zU_T(:, :, cc); aa = sort(aa,'ascend'); pUzU = mean(aa,2); aa = pU_zN_T(:, :, cc); aa = sort(aa,'ascend'); pUzN = mean(aa,2); aa = pU_zG_T(:, :, cc); aa = sort(aa,'ascend'); pUzG = mean(aa,2); aa = pU_zG2_T(:, :, cc); aa = sort(aa,'ascend'); pUzG2 = mean(aa,2); sp_hand1 = subplot(3,3, ccc); plot(pUzU, 1:n, 'k-','LineWidth',2); grid on; hold on; plot(pUzN, 1:n,'-','LineWidth',2,'Color',[0.011, 0.290, 0.517]); hold on; plot(pUzG, 1:n,'-','LineWidth',2,'Color',[0.545, 0.035, 0.035;]); hold on; plot(pUzG2, 1:n,'-','LineWidth',2,'Color',[0.945, 0.560, 0.486;]); set(gca,'FontName', 'DejaVuSans','FontSize',11, 'YTick', [0 250 500 750 1000]); if ccc == 1 title('ipc-U', 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); l1={ 'sne-U','sne-N','sne-\Gamma^R','sne-\Gamma^L' }; l2=legend(l1); % l2.Interpreter = 'latex'; set(l2, 'Position',[0.424895833333333 0.0130597014925373 0.235833333333333 0.0414593698175788],... 'Orientation','horizontal', 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVuSans'); end if cs == 1 || cs == 4 || cs ==7 ylabel('F_X(p)'); xlabel('p(T)'); end pos1 = get(sp_hand1, 'Position'); % gives the position of current sub-plot new_pos1 = pos1 +[-0.03 0 0.06 0.01]; set(sp_hand1, 'Position',new_pos1 ); axis([-.01 1.01 -10 1010]); cs = cs + 1; % casepN aa = pN_zU_T(:, :, cc); aa = sort(aa,'ascend'); pNzU = mean(aa,2); aa = pN_zN_T(:, :, cc); aa = sort(aa,'ascend'); pNzN = mean(aa,2); aa = pN_zG_T(:, :, cc); aa = sort(aa,'ascend'); pNzG = mean(aa,2); aa = pN_zG2_T(:, :, cc); aa = sort(aa,'ascend'); pNzG2 = mean(aa,2); sp_hand2 = subplot(3,3, ccc+1); plot(pNzU, 1:n, 'k-','LineWidth',2); grid on; hold on; plot(pNzN, 1:n,'-','LineWidth',2,'Color',[0.011, 0.290, 0.517]); hold on; plot(pNzG, 1:n,'-','LineWidth',2,'Color',[0.545, 0.035, 0.035;]); hold on; plot(pNzG2, 1:n,'-','LineWidth',2,'Color',[0.945, 0.560, 0.486;]); set(gca,'FontName', 'DejaVuSans','FontSize',11, 'YTick', [0 250 500 750 1000]); if ccc == 1 title('ipc-N', 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); end if cs == 2 ylabel('s = 0.2', 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); end if cs == 5 ylabel('s = 0.5', 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); end if cs == 8 ylabel('s = 0.8', 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); end pos2 = get(sp_hand2, 'Position'); % gives the position of current sub-plot new_pos2 = pos2 +[-0.008 0.0 0.06 0.01]; set(sp_hand2, 'Position',new_pos2 ); axis([-.01 1.01 -10 1010]); cs = cs + 1; % casepG aa = pG_zU_T(:, :, cc); aa = sort(aa,'ascend'); pGzU = mean(aa,2); aa = pG_zN_T(:, :, cc); aa = sort(aa,'ascend'); pGzN = mean(aa,2); aa = pG_zG_T(:, :, cc); aa = sort(aa,'ascend'); pGzG = mean(aa,2); aa = pG_zG2_T(:, :, cc); aa = sort(aa,'ascend'); pGzG2 = mean(aa,2); sp_hand3 = subplot(3,3, ccc+2); plot(pGzU, 1:n, 'k-','LineWidth',2); grid on; hold on; plot(pGzN, 1:n,'-','LineWidth',2,'Color',[0.011, 0.290, 0.517]); hold on; plot(pGzG, 1:n,'-','LineWidth',2,'Color',[0.545, 0.035, 0.035;]); hold on; plot(pGzG2, 1:n,'-','LineWidth',2,'Color',[0.945, 0.560, 0.486;]); set(gca,'FontName', 'DejaVuSans','FontSize',11, 'YTick', [0 250 500 750 1000]); tit = 'Case: ipc-\Gamma'; if ccc == 1 title('ipc-\Gamma', 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); end if cs == 8 || cs == 9 xlabel('p(T)'); end %ylabel('F_X(p)'); axis([-.01 1.01 -10 1010]); pos3 = get(sp_hand3, 'Position'); % gives the position of current sub-plot new_pos3 = pos3 +[0.02 0.0 0.06 0.01]; set(sp_hand3, 'Position',new_pos3 ); ccc = ccc +3; cs = cs +1; end %NOTE: move manually the yaxis with the "sne" legend on the right clear pUzU pUzN pUzG pUzG2 pNzU pNzN pNzG pNzG2 pGzU pGzN pGzG pGzG2 clear ccc cc aa %% individual dynamics all p with s=0.2 x = 1:T; id = 5; stepp = 50; cs = 2; %threshod s=0.2 nn = [id:stepp:n, 1000]; % https://doc.instantreality.org/tools/color_calculator/ % blue % #034a84: 0.011, 0.290, 0.517 % #4078a0: 0.250, 0.470, 0.627 % #7fa5bf; 0.498, 0.647, 0.749 % #bfd2df: 0.749, 0.823, 0.874 % % red % #e56b4a: 0.898, 0.419, 0.290 % #f18f7c: 0.945, 0.560, 0.486 % #f5b4a7: 0.960, 0.705, 0.654 % #fad9d3: 0.980, 0.850, 0.827 %clo = jet(nl); clo = [ 0.01, 0.1, 0.5; 0.011, 0.290, 0.517; 0.11, 0.35, 0.587; 0.250, 0.470, 0.627; 0.498, 0.647, 0.749; 0.749, 0.823, 0.874; .8, .8, .9; .8, .8, .8; .9, .8, .8; 0.980, 0.850, 0.827; 0.970, 0.755, 0.754; 0.960, 0.705, 0.654; 0.945, 0.560, 0.486; 0.898, 0.419, 0.290; 0.545, 0.035, 0.035; ]; nl =length(nn); % UNIFORM (pU) for k = 1:5 %pU pu = zeros(nl,T, 4); aa = pU_zU(nn, :,k, cs); aa = sort(aa,'descend'); pu(:,:, 1) = aa; aa = pU_zN(nn, :,k, cs); aa = sort(aa,'descend'); pu(:,:, 2) = aa; aa = pU_zG(nn, :,k, cs); aa = sort(aa,'descend'); pu(:,:, 3) = aa; aa = pU_zG2(nn, :,k, cs); aa = sort(aa,'descend'); pu(:,:, 4) = aa; %pN pN = zeros(nl,T, 4); aa = pN_zU(nn, :,k, cs); aa = sort(aa,'descend'); pN(:,:, 1) = aa; aa = pN_zN(nn, :,k, cs); aa = sort(aa,'descend'); pN(:,:, 2) = aa; aa = pN_zG(nn, :,k, cs); aa = sort(aa,'descend'); pN(:,:, 3) = aa; aa = pN_zG2(nn, :,k, cs); aa = sort(aa,'descend'); pN(:,:, 4) = aa; %pG pG = zeros(nl,T, 4); aa = pG_zU(nn, :,k, cs); aa = sort(aa,'descend'); pG(:,:, 1) = aa; aa = pG_zN(nn, :,k, cs); aa = sort(aa,'descend'); pG(:,:, 2) = aa; aa = pG_zG(nn, :,k, cs); aa = sort(aa,'descend'); pG(:,:, 3) = aa; aa = pG_zG2(nn, :,k, cs); aa = sort(aa,'descend'); pG(:,:, 4) = aa; clear i end %% figure figure('units', 'normalized', 'outerposition', [-0.0046875 0.03796 1.009375 0.970]) m = 1; for jj = 1:4 %%%%%%%%%%%%%%%pU sp_hand1 = subplot(4,3, m); c=1; for i = 1:nl plot(x, 100*pu(i,:, jj),'-','Color',clo(c,:),'LineWidth',1.5);hold on; grid on; c = c+1; end set(gca,'FontName', 'DejaVuSans','FontSize',13 ,'YTick', 0:25:100 ); line([0 T], [100*cs/10 100*cs/10],'Color',[0 0 0], 'LineStyle','--'); if m== 1 tit = title('ipc-U'); set(tit, 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); end pos1 = get(sp_hand1, 'Position'); % gives the position of current sub-plot new_pos1 = pos1 +[-0.03 0 0.06 0.01]; set(sp_hand1, 'Position',new_pos1 ); axis([0 1+T 0 101]); ylabel('p_j','Rotation',0); %%%%%%%%%%%%%%%pN sp_hand2 =subplot(4,3, m+1); c=1; for i = 1:nl plot(x, 100*pN(i,:, jj),'-','Color',clo(c,:),'LineWidth',1.5);hold on; grid on; c = c+1; end line([0 T], [100*cs/10 100*cs/10],'Color',[0 0 0], 'LineStyle','--'); set(gca,'FontName', 'DejaVuSans','FontSize',13,'YTick', 0:25:100 ); line([0 T], [100*cs/10 100*cs/10],'Color',[0 0 0], 'LineStyle','--'); if m== 1 tit = title('ipc-N'); set(tit, 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); end ylabel('sne-U', 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); pos2 = get(sp_hand2, 'Position'); % gives the position of current sub-plot new_pos2 = pos2 +[-0.008 0.0 0.06 0.01]; set(sp_hand2, 'Position',new_pos2 ); axis([0 1+T 0 101]); c = 1; %%%%%%%%%%%%%%%pN sp_hand3 = subplot(4,3, m+2); for i = 1:nl plot(x, 100*pG(i,:, jj),'-','Color',clo(c,:),'LineWidth',1.5);hold on; grid on; c = c+1; end set(gca,'FontName', 'DejaVuSans','FontSize',13,'YTick', 0:25:100 ); line([0 T], [100*cs/10 100*cs/10],'Color',[0 0 0], 'LineStyle','--'); if m== 1 tit = title('ipc-\Gamma'); set(tit, 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); end%,' (s =',num2str(s(cs)),')' )); pos3 = get(sp_hand3, 'Position'); % gives the position of current sub-plot new_pos3 = pos3 +[0.02 0.0 0.06 0.01]; set(sp_hand3, 'Position',new_pos3 ); axis([0 1+T 0 101]); m = m+3; end colormap %add colorbar with the bar menu of the figure %move manually the ylabel with the sne cases on the left %% contribution contrib_pU = zeros(4,9); contrib_pN = zeros(4,9); contrib_pG = zeros(4,9); for cs =1:9 % 1, zU pc = mean(pU_zU_T(:, :,cs),2); % relative frequeency of each prob contrib_pU(1,cs) = sum(pc)/1000; pc = mean(pN_zU_T(:, :,cs),2); % relative frequeency of each prob contrib_pN(1,cs) = sum(pc)/1000; pc = mean(pG_zU_T(:, :,cs),2); % relative frequeency of each prob contrib_pG(1,cs) = sum(pc)/1000; % 2, zN pc = mean(pU_zN_T(:, :,cs),2); % relative frequeency of each prob contrib_pU(2,cs) = sum(pc)/1000; pc = mean(pN_zN_T(:, :,cs),2); % relative frequeency of each prob contrib_pN(2,cs) = sum(pc)/1000; pc = mean(pG_zN_T(:, :,cs),2); % relative frequeency of each prob contrib_pG(2,cs) = sum(pc)/1000; % 3, zG pc = mean(pU_zG_T(:, :,cs),2); % relative frequeency of each prob contrib_pU(3,cs) = sum(pc)/1000; pc = mean(pN_zG_T(:, :,cs),2); % relative frequeency of each prob contrib_pN(3,cs) = sum(pc)/1000; pc = mean(pG_zG_T(:, :,cs),2); % relative frequeency of each prob contrib_pG(3,cs) = sum(pc)/1000; % 4, zG2 pc = mean(pU_zG2_T(:, :,cs),2); % relative frequeency of each prob contrib_pU(4,cs) = sum(pc)/1000; pc = mean(pN_zG2_T(:, :,cs),2); % relative frequeency of each prob contrib_pN(4,cs) = sum(pc)/1000; pc = mean(pG_zG2_T(:, :,cs),2); % relative frequeency of each prob contrib_pG(4,cs) = sum(pc)/1000; end % colcol = [0 50 75,... % 100 21 21,... % 30 75 90,... % 100 55 55,... % 45 65 20]/100; %% colcol = [0,0,0; 0.011, 0.290, 0.517; 0.545, 0.035, 0.035; 0.945, 0.560, 0.486]; cas = {'sne-U', 'sne-N', 'sne-\Gamma^R', 'sne-\Gamma^L'}; figure('units', 'normalized', 'outerposition', [-0.0046875 0.03796 1.009375 0.970]) % Uniform sp_hand1 = subplot(1,3, 1); for ii = 1:4 plot(s, 100*contrib_pU(ii,:),'-h','LineWidth',2,'Color',colcol(ii,:)); hold on; grid on; end xlabel('Threshold (s)'); ylabel('ASC'); title('ipc-U', 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); set(gca,'FontName', 'DejaVuSans','FontSize',15, 'XTick', .1:.1:.9 ); axis([0.07 0.93 10 90]); pos1 = get(sp_hand1, 'Position'); % gives the position of current sub-plot new_pos1 = pos1 +[-0.08 0 0.06 0.01]; set(sp_hand1, 'Position',new_pos1 ); % Gaussian sp_hand2= subplot(1,3, 2); for ii = 1:4 plot(s, 100*contrib_pN(ii,:),'-h','LineWidth',2,'Color',colcol(ii,:)); hold on; grid on; end xlabel('Threshold (s)'); ylabel('ASC'); title('ipc-N', 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); set(gca,'FontName', 'DejaVuSans','FontSize',13,... 'XTick', .1:.1:.9 ); axis([0.07 0.93 10 90]); pos2 = get(sp_hand2, 'Position'); % gives the position of current sub-plot new_pos2 = pos2 + [-0.03 0.0 0.06 0.01]; set(sp_hand2, 'Position',new_pos2 ); % Gamma sp_hand3 = subplot(1,3, 3); for ii = 1:4 plot(s, 100*contrib_pG(ii,:),'-h','LineWidth',2,'Color',colcol(ii,:)); hold on; grid on; end xlabel('Threshold (s)'); ylabel('ASC'); title('ipc-\Gamma', 'EdgeColor',[0.149019607843137 0.149019607843137 0.149019607843137],... 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVu Sans'); set(gca,'FontName', 'DejaVuSans','FontSize',13,... 'XTick', .1:.1:.9 ); l1=cas; l2=legend(l1); %l2.Interpreter = 'latex'; set(l2, 'Position',[0.424895833333333 0.0130597014925373 0.235833333333333 0.0414593698175788],... 'Orientation','horizontal', 'FontWeight','bold', 'FontAngle','italic', 'FontSize',18, 'FontName','DejaVuSans'); axis([0.07 0.93 10 90]); pos3 = get(sp_hand3, 'Position'); % gives the position of current sub-plot new_pos3 = pos3 +[0.02 0 0.06 0.01]; set(sp_hand3, 'Position',new_pos3 );