clear, close all
addpath(genpath(pwd));

num_experiments=100;  % 随机试验次数

% Predicted porosity vs Real porosity 
y_test_all=[];
yy_test_all=[];
sd_test_all=[];

for k=1:num_experiments
    sd_test_single=[];
    for q=1:5
        % 导入测试集真值
        filepath=sprintf('%s%d%s%d%s','..\data\intermediate\MDN_multitests_results\y_test_experiment',k,'_well',q,'.mat');
        load(filepath);
        y_test_all=[y_test_all;y_test];
        
        % 导入测试集预测值
        filepath=sprintf('%s%d%s%d%s','..\data\intermediate\MDN_multitests_results\yy_test_experiment',k,'_well',q,'.mat');
        load(filepath);
        yy_test_all=[yy_test_all;yy_test];

        % 导入测试集不确定性
        filepath=sprintf('%s%d%s%d%s','..\data\intermediate\MDN_multitests_results\sd_test_experiment',k,'_well',q,'.mat');
        load(filepath);
        sd_test_all=[sd_test_all;sd_test];
    end
end


hfig=figure;
set(hfig,'color','w');
scatter(y_test_all,yy_test_all,80,sd_test_all,'linewidth',1.5);hold on;
colormap(flipud(hot));
h=colorbar;
caxis([0,0.04]);
set(h,'ytick',[]);
set(get(h,'title'),'string','SD');
set(gca,'LineWidth',2,'FontSize',20,'FontWeight','bold','box','on');
xlabel('Real porosity','FontSize',20,'FontWeight','bold');
ylabel('Predicted porosity','FontSize',20,'FontWeight','bold');
axis square
xlim([0,0.21]);
ylim([0,0.21]);
set(gca,'xtick',0:0.05:0.2,'ytick',0:0.05:0.2);
xlims=get(gca,'xlim');
x=linspace(xlims(1),xlims(2),100);
y=x;
plot(x,y,'linewidth',2,'color','k');


% AE vs SD
error_test=y_test_all-yy_test_all;
ae_test=abs(error_test);

hfig=figure;
set(hfig,'color','w');
scatter(sd_test_all,ae_test,80,'MarkerEdgeColor',[0 .5 .5],'MarkerFaceColor',[0 .7 .7],'linewidth',1.5);hold on;
set(gca,'LineWidth',2,'FontSize',20,'FontWeight','bold','box','on');
xlabel('Standard deviation','FontSize',20,'FontWeight','bold');
ylabel('Absolute error','FontSize',20,'FontWeight','bold');
xlim([0,max(sd_test_all)]);
ylim([0,max(ae_test)]);
