function TRI_Experiment_figure(SIM)

all_U_SORT_min_delay = SIM(:, 5) .* SIM(:, 8);
all_U_SORT_fair_delay = SIM(:, 6) .* SIM(:, 8);
all_FCFS_delay = SIM(:, 7) .* SIM(:, 8);

paired_t_test_improvement(all_U_SORT_min_delay, all_U_SORT_fair_delay,"min和fair的总体差别");
paired_t_test_improvement(all_U_SORT_min_delay, all_FCFS_delay,"min和FCFS的总体差别");
paired_t_test_improvement(all_U_SORT_fair_delay, all_FCFS_delay,"fair和FCFS的总体差别");

lmbda_mean_figure = SIM(SIM(:, 2) == 24 & SIM(:,4) == 0, :);
lambda = lmbda_mean_figure(:, 1);
mean = lmbda_mean_figure(:, 3);

pressure_U_SORT_min_delay = lmbda_mean_figure(:, 5);
pressure_U_SORT_fair_delay = lmbda_mean_figure(:, 6);
pressure_FCFS_delay = lmbda_mean_figure(:, 7);

[LambdaGrid, MeanGrid] = meshgrid(unique(lambda), unique(mean));
Z1 = reshape(pressure_U_SORT_min_delay, size(LambdaGrid));
Z2 = reshape(pressure_U_SORT_fair_delay, size(LambdaGrid));
Z3 = reshape(pressure_FCFS_delay, size(LambdaGrid));


figure;
h1 = surf(LambdaGrid, MeanGrid, Z1, 'FaceColor', 'red', 'FaceAlpha', 0.5);
hold on
h2 = surf(LambdaGrid, MeanGrid, Z2, 'FaceColor', 'green', 'FaceAlpha', 0.5);
hold on 
h3 = surf(LambdaGrid, MeanGrid, Z3, 'FaceColor', 'blue', 'FaceAlpha', 0.5);
xlabel('Arrival rate (\lambda)', 'FontSize', 14);
ylabel('Duration Mean', 'FontSize', 14);
zlabel('Percentage of Delay patients in total patients', 'FontSize', 14);
title('Stress Testing: U-SORT-min, U-SORT-fair, and FCFS Methods');
legend([h1, h2, h3], {'U-SORT-min', 'U-SORT-fair', 'FCFS'}, 'Location', 'Best');
set(gcf, 'Position', [100, 100, 600, 500]);
hold off;
saveas(figure(1), 'U-SORTVSFCFS_lambda.png');

paired_t_test_improvement(pressure_U_SORT_min_delay, pressure_U_SORT_fair_delay,"min和fair的压力差别");
paired_t_test_improvement(pressure_U_SORT_min_delay, pressure_FCFS_delay,"min和FCFS的压力差别");
paired_t_test_improvement(pressure_U_SORT_fair_delay, pressure_FCFS_delay,"fair和FCFS的压力差别");

T_figure = SIM(abs(SIM(:, 1) - 1.2) < 0.01 & SIM(:,3) == 1 & SIM(:,4) == 0, :);
T = T_figure(:, 2);

T_U_SORT_min_delay = T_figure(:, 5);
T_U_SORT_fair_delay = T_figure(:, 6);
T_FCFS_delay = T_figure(:, 7);

figure;
h1 = plot(T, T_U_SORT_min_delay, 'LineStyle', '-');
hold on
h2 = plot(T, T_U_SORT_fair_delay, 'LineStyle', '--');
hold on
h3 = plot(T, T_FCFS_delay, 'LineStyle', '-.');
xlabel('T', 'FontSize', 14);
ylabel('The percentage of delayed patients', 'FontSize', 14);
title('Long-term Testing: U-SORT-min, U-SORT-fair, and FCFS Methods');
legend([h1, h2, h3], {'U-SORT-min', 'U-SORT-fair', 'FCFS'}, 'Location', 'Best');
set(gcf, 'Position', [100, 100, 600, 500]);
hold off;
saveas(figure(2), 'U-long_term_USORTVSFCFS.png');

paired_t_test_improvement(T_U_SORT_min_delay, T_U_SORT_fair_delay,"min和fair的边界差别");
paired_t_test_improvement(T_U_SORT_min_delay, T_FCFS_delay,"min和FCFS的边界差别");
paired_t_test_improvement(T_U_SORT_fair_delay, T_FCFS_delay,"fair和FCFS的边界差别");

prob_list = [0.05; 0.6; 0.35];
slots = [0, 3; 3, 12; 12, 24];
U_SORT_min_var_list = [];
U_SORT_fair_var_list = [];
FCFS_var_list = [];
d_var_list = [];

for d_var = 0:0.1:1
    d_var_list = [d_var_list, d_var];
    temp_U_SORT_min_var_list = [];
    temp_U_SORT_fair_var_list = [];
    temp_FCFS_var_list = [];
    rng('default');
    for times = 1:10

        patients = TRI_CY_arrivals(1,24,prob_list,2,d_var,0.5);

        p_queue = TRI_CY_p_queue_method(patients,slots, 0, 10);
        U_SORT_EMR = TRI_CY_p_queue_to_EMR(patients, p_queue, slots);
        temp_U_SORT_min_var_list = [temp_U_SORT_min_var_list, numel(find(U_SORT_EMR(:, 6) > 0))];

        p_queue = TRI_CY_p_queue_method(patients,slots, 1, 10);
        U_SORT_EMR = TRI_CY_p_queue_to_EMR(patients, p_queue, slots);
        temp_U_SORT_fair_var_list = [temp_U_SORT_fair_var_list, numel(find(U_SORT_EMR(:, 6) > 0))];

        FCFS_EMR = TRI_CY_sim_1C1S(patients, slots, 0, 24, 100);
        temp_FCFS_var_list = [temp_FCFS_var_list, numel(find(FCFS_EMR(:, 6) > 0))];

    end
    U_SORT_min_var_list = [U_SORT_min_var_list; temp_U_SORT_min_var_list];
    U_SORT_fair_var_list = [U_SORT_fair_var_list; temp_U_SORT_fair_var_list];
    FCFS_var_list = [FCFS_var_list; temp_FCFS_var_list];
end
U_SORT_min_var = var(U_SORT_min_var_list, 0 ,2);
U_SORT_fair_var = var(U_SORT_fair_var_list, 0 ,2);
FCFS_var = var(FCFS_var_list, 0 ,2);

figure;
h1 = plot(d_var_list, U_SORT_min_var, 'LineStyle', '-');
hold on
h2 = plot(d_var_list, U_SORT_fair_var, 'LineStyle', '--');
hold on
h3 = plot(d_var_list, FCFS_var, 'LineStyle', '-.');
xlabel('Duration Variance', 'FontSize', 14);
ylabel('Delayed Patients Variance', 'FontSize', 14);
title('Stability test: U-SORT-min, U-SORT-fair, and FCFS Methods');
legend([h1, h2, h3], {'U-SORT-min', 'U-SORT-fair', 'FCFS'}, 'Location', 'Best');
set(gcf, 'Position', [100, 100, 600, 500]);
hold off;
saveas(figure(3), 'U-stability_USORTVSFCFS.png');

not_significant = [];
significant = [];

for index = 1:15840
    
    temp = SIM(index, :);
    difference = abs(temp(5) - temp(6));
    if difference <= 0.01
        not_significant = [not_significant; temp];
    else
        significant = [significant; temp];
    end

end

not_significant_sets = not_significant(:, 1:4);
not_significant_fair = not_significant(:, 6) .* not_significant(:, 8);
not_significant_min = not_significant(:, 5) .* not_significant(:, 8);

significant_sets = significant(:, 1:4);
significant_fair = significant(:, 6) .* significant(:, 8);
significant_min = significant(:, 5) .* significant(:, 8);

value_name = ["lambda", "T", "d_{mu}", "d_{var}"];

figure;
for i = 1:4
    subplot(2, 2, i);
    histogram(not_significant_sets(:, i));
    title(['Histogram of Var', value_name(i), ' in Non-significant Sets']);
    xlabel('Amount of value');
    ylabel('Frequency');
end
set(gcf, 'Position', [100, 100, 600, 500]);
saveas(figure(4), 'Non-significant_Sets.png');

figure;
for i = 1:4
    subplot(2, 2, i);
    histogram(significant_sets(:, i));
    title(['Histogram of Var', value_name(i), ' in Significant Sets']);
    xlabel('Amount of value');
    ylabel('Frequency');
end
set(gcf, 'Position', [100, 100, 600, 500]);
saveas(figure(5), 'Significant_Sets.png');

paired_t_test_improvement(not_significant_min, not_significant_fair,"不显著情况下");
paired_t_test_improvement(significant_min, significant_fair,"显著情况下");