Skip to content

Instantly share code, notes, and snippets.

@evandrocoan
Last active March 19, 2021 16:27
Show Gist options
  • Save evandrocoan/a8433563c10dd12f7ece0c93cdc1fa19 to your computer and use it in GitHub Desktop.
Save evandrocoan/a8433563c10dd12f7ece0c93cdc1fa19 to your computer and use it in GitHub Desktop.
Attempts to predict how much time will take until the next Sublime Text release: https://forum.sublimetext.com/t/for-when-the-new-version/34974
#!/usr/bin/env octave
%{
# Licensing - Graphics
# Copyright (C) 2018 Evandro Coan <https://github.com/evandrocoan>
#
# OS ARQUIVOS NESTE REPOSITÓRIO SÃO FORNECIDOS "NO ESTADO EM QUE SE ENCONTRAM", SEM GARANTIA DE
# QUALQUER TIPO, EXPRESSA OU IMPLÍCITA, INCLUINDO, MAS NÃO SE LIMITANDO ÀS GARANTIAS DE
# COMERCIALIZAÇÃO, APTIDÃO PARA UM PROPÓSITO ESPECÍFICO E NÃO INFRACÇÃO. EM NENHUMA CIRCUNSTÂNCIA, OS
# AUTORES OU TITULARES DE DIREITOS AUTORAIS SERÃO RESPONSÁVEIS POR QUALQUER RECLAMAÇÃO, DANOS OU OUTRA
# RESPONSABILIDADE, SEJA EM AÇÃO DE CONTRATO, DELITO OU DE OUTRA FORMA, DECORRENTE, DESTE OU
# RELACIONADO COM DOS ARQUIVOS DESTE REPOSITÓRIO OU O USO OU OUTRAS NEGOCIAÇÕES NO MODELO E SOFTWARE.
#
Source Data:
BUILD 3143, date(2017 , 9 , 13) - date(2016 , 9 , 23) = 355 days
BUILD 3126, date(2016 , 9 , 23) - date(2016 , 9 , 22) = 1 days
BUILD 3124, date(2016 , 9 , 22) - date(2016 , 5 , 12) = 133 days
BUILD 3114, date(2016 , 5 , 12) - date(2016 , 2 , 9) = 93 days
BUILD 3103, date(2016 , 2 , 9) - date(2015 , 3 , 26) = 320 days
BUILD 3083, date(2015 , 3 , 26) - date(2015 , 3 , 24) = 2 days
BUILD 3080, date(2015 , 3 , 24) - date(2014 , 8 , 27) = 209 days
BUILD 3065, date(2014 , 8 , 27) - date(2013 , 12 , 17) = 253 days
BUILD 3059, date(2013 , 12 , 17) - date(2013 , 6 , 27) = 173 days
BUILD 3047, date(2013 , 6 , 27) - date(2013 , 5 , 7) = 51 days
BUILD 3033, date(2013 , 5 , 7) - date(2013 , 3 , 14) = 54 days
BUILD 3021, date(2013 , 3 , 14) - date(2013 , 3 , 12) = 2 days
BUILD 3019, date(2013 , 3 , 12) - date(2013 , 2 , 10) = 30 days
BUILD 3012, date(2013 , 2 , 10) - date(2013 , 2 , 9) = 1 days
BUILD 3011, date(2013 , 2 , 9) - date(2013 , 2 , 3) = 6 days
BUILD 3010, date(2013 , 2 , 3) - date(2013 , 2 , 1) = 2 days
BUILD 3009, date(2013 , 2 , 1) - date(2013 , 1 , 30) = 2 days
BUILD 3008, date(2013 , 1 , 30) - date(2013 , 1 , 30) = 0 days
BUILD 3007, date(2013 , 1 , 30) - date(2013 , 1 , 29) = 1 days
BUILD 3006,
BUILD 3156, date(2017, 12, 2) - date(2017, 11, 30) = 2 days
BUILD 3155, date(2017, 11, 30) - date(2017, 11, 11) = 19 days
BUILD 3154, date(2017, 11, 11) - date(2017, 11, 1) = 10 days
BUILD 3153, date(2017, 11, 1) - date(2017, 10, 20) = 12 days
BUILD 3152, date(2017, 10, 20) - date(2017, 10, 17) = 3 days
BUILD 3150, date(2017, 10, 17) - date(2017, 10, 13) = 4 days
BUILD 3149, date(2017, 10, 13) - date(2017, 10, 10) = 3 days
BUILD 3148, date(2017, 10, 10) - date(2017, 10, 6) = 4 days
BUILD 3147, date(2017, 10, 6) - date(2017, 10, 6) = 0 days
BUILD 3146, date(2017, 10, 6) - date(2017, 9, 14) = 22 days
BUILD 3144, date(2017, 9, 14) - date(2017, 7, 27) = 49 days
BUILD 3142, date(2017, 7, 27) - date(2017, 7, 7) = 20 days
BUILD 3141, date(2017, 7, 7) - date(2017, 6, 30) = 7 days
BUILD 3140, date(2017, 6, 30) - date(2017, 6, 20) = 10 days
BUILD 3139, date(2017, 6, 20) - date(2017, 6, 20) = 0 days
BUILD 3138, date(2017, 6, 20) - date(2017, 6, 13) = 7 days
BUILD 3136, date(2017, 6, 13) - date(2017, 6, 12) = 1 days
BUILD 3135, date(2017, 6, 12) - date(2017, 6, 9) = 3 days
BUILD 3134, date(2017, 6, 9) - date(2017, 6, 2) = 7 days
BUILD 3133, date(2017, 6, 2) - date(2017, 5, 26) = 7 days
BUILD 3132, date(2017, 5, 26) - date(2017, 4, 22) = 34 days
BUILD 3131, date(2017, 4, 22) - date(2017, 4, 21) = 1 days
BUILD 3130, date(2017, 4, 21) - date(2017, 4, 13) = 8 days
BUILD 3129, date(2017, 4, 13) - date(2017, 4, 12) = 1 days
BUILD 3128, date(2017, 4, 12) - date(2017, 4, 12) = 0 days
BUILD 3127, date(2017, 4, 12) - date(2016, 9, 23) = 201 days
BUILD 3125, date(2016, 9, 23) - date(2016, 9, 21) = 2 days
BUILD 3123, date(2016, 9, 21) - date(2016, 9, 15) = 6 days
BUILD 3122, date(2016, 9, 15) - date(2016, 9, 14) = 1 days
BUILD 3121, date(2016, 9, 14) - date(2016, 7, 28) = 48 days
BUILD 3120, date(2016, 7, 28) - date(2016, 7, 26) = 2 days
BUILD 3119, date(2016, 7, 26) - date(2016, 6, 28) = 28 days
BUILD 3118, date(2016, 6, 28) - date(2016, 6, 22) = 6 days
BUILD 3117, date(2016, 6, 22) - date(2016, 6, 22) = 0 days
BUILD 3116, date(2016, 6, 22) - date(2016, 5, 11) = 42 days
BUILD 3113, date(2016, 5, 11) - date(2016, 5, 5) = 6 days
BUILD 3112, date(2016, 5, 5) - date(2016, 4, 13) = 22 days
BUILD 3111, date(2016, 4, 13) - date(2016, 4, 12) = 1 days
BUILD 3110, date(2016, 4, 12) - date(2016, 3, 18) = 25 days
BUILD 3109, date(2016, 3, 18) - date(2016, 2, 25) = 22 days
BUILD 3107, date(2016, 2, 25) - date(2016, 2, 24) = 1 days
BUILD 3106, date(2016, 2, 24) - date(2016, 2, 18) = 6 days
BUILD 3105, date(2016, 2, 18) - date(2016, 2, 17) = 1 days
BUILD 3104, date(2016, 2, 17) - date(2016, 2, 8) = 9 days
BUILD 3102, date(2016, 2, 8) - date(2016, 2, 5) = 3 days
BUILD 3101, date(2016, 2, 5) - date(2016, 2, 3) = 2 days
BUILD 3100, date(2016, 2, 3) - date(2016, 1, 29) = 5 days
BUILD 3099, date(2016, 1, 29) - date(2016, 1, 29) = 0 days
BUILD 3098, date(2016, 1, 29) - date(2015, 7, 10) = 203 days
BUILD 3095, date(2015, 7, 10) - date(2015, 7, 2) = 8 days
BUILD 3094, date(2015, 7, 2) - date(2015, 7, 1) = 1 days
BUILD 3093, date(2015, 7, 1) - date(2015, 6, 4) = 27 days
BUILD 3092, date(2015, 6, 4) - date(2015, 6, 2) = 2 days
BUILD 3091, date(2015, 6, 2) - date(2015, 6, 2) = 0 days
BUILD 3090, date(2015, 6, 2) - date(2015, 5, 27) = 6 days
BUILD 3088, date(2015, 5, 27) - date(2015, 5, 26) = 1 days
BUILD 3087, date(2015, 5, 26) - date(2015, 5, 12) = 14 days
BUILD 3086, date(2015, 5, 12) - date(2015, 5, 5) = 7 days
BUILD 3085, date(2015, 5, 5) - date(2015, 4, 8) = 27 days
BUILD 3084, date(2015, 4, 8) - date(2015, 3, 26) = 13 days
BUILD 3082, date(2015, 3, 26) - date(2015, 3, 25) = 1 days
BUILD 3081, date(2015, 3, 25) - date(2015, 3, 20) = 5 days
BUILD 3079, date(2015, 3, 20) - date(2015, 3, 19) = 1 days
BUILD 3078, date(2015, 3, 19) - date(2015, 3, 19) = 0 days
BUILD 3077, date(2015, 3, 19) - date(2015, 3, 10) = 9 days
BUILD 3075, date(2015, 3, 10) - date(2015, 3, 3) = 7 days
BUILD 3074, date(2015, 3, 3) - date(2015, 2, 28) = 3 days
BUILD 3073, date(2015, 2, 28) - date(2015, 2, 27) = 1 days
BUILD 3072, date(2015, 2, 27) - date(2015, 2, 20) = 7 days
BUILD 3071, date(2015, 2, 20) - date(2015, 2, 17) = 3 days
BUILD 3070, date(2015, 2, 17) - date(2015, 2, 4) = 13 days
BUILD 3069, date(2015, 2, 4) - date(2015, 2, 3) = 1 days
BUILD 3068, date(2015, 2, 3) - date(2015, 1, 30) = 4 days
BUILD 3067, date(2015, 1, 30) - date(2014, 10, 16) = 106 days
BUILD 3066, date(2014, 10, 16) - date(2014, 8, 27) = 50 days
BUILD 3064, date(2014, 8, 27) - date(2014, 8, 26) = 1 days
BUILD 3063, date(2014, 8, 26) - date(2014, 5, 5) = 113 days
BUILD 3062, date(2014, 5, 5) - date(2013, 12, 21) = 135 days
BUILD 3061, date(2013, 12, 21) - date(2013, 12, 12) = 9 days
BUILD 3058, date(2013, 12, 12) - date(2013, 12, 10) = 2 days
BUILD 3057, date(2013, 12, 10) - date(2013, 11, 20) = 20 days
BUILD 3056, date(2013, 11, 20) - date(2013, 11, 19) = 1 days
BUILD 3055, date(2013, 11, 19) - date(2013, 10, 16) = 34 days
BUILD 3054, date(2013, 10, 16) - date(2013, 8, 30) = 47 days
BUILD 3053, date(2013, 8, 30) - date(2013, 7, 23) = 38 days
BUILD 3052, date(2013, 7, 23) - date(2013, 7, 22) = 1 days
BUILD 3050, date(2013, 7, 22) - date(2013, 7, 19) = 3 days
BUILD 3049, date(2013, 7, 19) - date(2013, 7, 10) = 9 days
BUILD 3048, date(2013, 7, 10) - date(2013, 6, 26) = 14 days
BUILD 3046, date(2013, 6, 26) - date(2013, 6, 25) = 1 days
BUILD 3045, date(2013, 6, 25) - date(2013, 6, 24) = 1 days
BUILD 3044, date(2013, 6, 24) - date(2013, 6, 21) = 3 days
BUILD 3043, date(2013, 6, 21) - date(2013, 6, 14) = 7 days
BUILD 3041, date(2013, 6, 14) - date(2013, 6, 13) = 1 days
BUILD 3040, date(2013, 6, 13) - date(2013, 6, 9) = 4 days
BUILD 3038, date(2013, 6, 9) - date(2013, 6, 4) = 5 days
BUILD 3037, date(2013, 6, 4) - date(2013, 6, 4) = 0 days
BUILD 3036, date(2013, 6, 4) - date(2013, 5, 17) = 18 days
BUILD 3035, date(2013, 5, 17) - date(2013, 5, 16) = 1 days
BUILD 3034, date(2013, 5, 16) - date(2013, 5, 6) = 10 days
BUILD 3032, date(2013, 5, 6) - date(2013, 5, 1) = 5 days
BUILD 3031, date(2013, 5, 1) - date(2013, 4, 23) = 8 days
BUILD 3030, date(2013, 4, 23) - date(2013, 4, 22) = 1 days
BUILD 3029, date(2013, 4, 22) - date(2013, 4, 16) = 6 days
BUILD 3028, date(2013, 4, 16) - date(2013, 4, 15) = 1 days
BUILD 3027, date(2013, 4, 15) - date(2013, 4, 10) = 5 days
BUILD 3026, date(2013, 4, 10) - date(2013, 4, 9) = 1 days
BUILD 3025, date(2013, 4, 9) - date(2013, 4, 8) = 1 days
BUILD 3024, date(2013, 4, 8) - date(2013, 4, 3) = 5 days
BUILD 3023, date(2013, 4, 3) - date(2013, 3, 18) = 16 days
BUILD 3022, date(2013, 3, 18) - date(2013, 3, 13) = 5 days
BUILD 3020, date(2013, 3, 13) - date(2013, 3, 11) = 2 days
BUILD 3018, date(2013, 3, 11) - date(2013, 3, 7) = 4 days
BUILD 3017, date(2013, 3, 7) - date(2013, 3, 6) = 1 days
BUILD 3016, date(2013, 3, 6) - date(2013, 3, 4) = 2 days
BUILD 3015, date(2013, 3, 4) - date(2013, 2, 28) = 4 days
BUILD 3014, date(2013, 2, 28) - date(2013, 2, 21) = 7 days
BUILD 3013,
%}
clc
clear
close all
format long
% warning on verbose
warning('off', 'MATLAB:polyfit:PolyNotUnique')
warning('off', 'MATLAB:polyfit:RepeatedPointsOrRescale')
x_stable = [3007, 3008, 3009, 3010, 3011, 3012, 3019, 3021, 3033, 3047, 3059, 3065, 3080, 3083, 3103, 3114, 3124, 3126, 3143];
y_stable = [1, 0, 2, 2, 6, 1, 30, 2, 54, 51, 173, 253, 209, 2, 320, 93, 133, 1, 355];
x_dev = [3014, 3015, 3016, 3017, 3018, 3020, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, ...
3031, 3032, 3034, 3035, 3036, 3037, 3038, 3040, 3041, 3043, 3044, 3045, 3046, 3048, 3049, 3050, ...
3052, 3053, 3054, 3055, 3056, 3057, 3058, 3061, 3062, 3063, 3064, 3066, 3067, 3068, 3069, 3070, ...
3071, 3072, 3073, 3074, 3075, 3077, 3078, 3079, 3081, 3082, 3084, 3085, 3086, 3087, 3088, 3090, ...
3091, 3092, 3093, 3094, 3095, 3098, 3099, 3100, 3101, 3102, 3104, 3105, 3106, 3107, 3109, 3110, ...
3111, 3112, 3113, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3125, 3127, 3128, 3129, 3130, ...
3131, 3132, 3133, 3134, 3135, 3136, 3138, 3139, 3140, 3141, 3142, 3144, 3146, 3147, 3148, 3149, ...
3150, 3152, 3153, 3154, 3155, 3156];
y_dev=[7, 4, 2, 1, 4, 2, 5, 16, 5, 1, 1, 5, 1, 6, 1, 8, 5, 10, 1, 18, 0, 5, 4, 1, 7, 3, 1, 1, 14, 9, ...
3, 1, 38, 47, 34, 1, 20, 2, 9, 135, 113, 1, 50, 106, 4, 1, 13, 3, 7, 1, 3, 7, 9, 0, 1, 5, 1, 13, 27, ...
7, 14, 1, 6, 0, 2, 27, 1, 8, 203, 0, 5, 2, 3, 9, 1, 6, 1, 22, 25, 1, 22, 6, 42, 0, 6, 28, 2, 48, 1, ...
6, 2, 201, 0, 1, 8, 1, 34, 7, 7, 3, 1, 7, 0, 10, 7, 20, 49, 22, 0, 4, 3, 4, 3, 12, 10, 19, 2];
next_dev_builds = [];
next_stable_builds = [];
% Creates a nth polynoms with degrees to approximate the the next build release date
next_extected_builds = [3157, 3358, 3359, 3360];
for index = 1 : 10
stable_polyfit = polyfit( x_stable, y_stable, index );
stable_mean = polyval( stable_polyfit, x_stable );
next_stable_builds{end+1} = polyval( stable_polyfit, next_extected_builds );
end
for index = 1 : 10
dev_polyfit = polyfit( x_dev, y_dev, index );
dev_mean = polyval( dev_polyfit, x_dev );
next_dev_builds{end+1} = polyval( dev_polyfit, next_extected_builds );
end
% Print the polynoms results to the standard output stream
fprintf( 1, 'next_stable_builds: \n ' )
fprintf( 1, '%10g ', next_extected_builds )
fprintf( 1, '\n' )
for index = 1 : length( next_stable_builds )
fprintf( 1, '%02d. ', index )
fprintf( 1, '%10g ', next_stable_builds{index} )
fprintf( 1, '\n' )
end
fprintf( 1, '\n' )
fprintf( 1, 'next_dev_builds: \n' )
for index = 1 : length( next_dev_builds )
fprintf( 1, '%02d. ', index )
fprintf( 1, '%10g ', next_dev_builds{index} )
fprintf( 1, '\n' )
end
% Plot the polynoms as graphs
figure(1);
hold all;
legends = [];
linewidth = 2.0;
linewidth_small = 0.1;
colors_for_the_grath = {[0.0,0.0,0.0], [1.0,0.0,0.0], [0.0,1.0,0.0], [0.0,0.0,1.0], ...
[0.0,1.0,1.0], [1.0,0.0,1.0], ...
[0.7529411764705882,0.7529411764705882,0.7529411764705882], ...
[0.5019607843137255,0.5019607843137255,0.5019607843137255], [0.5019607843137255,0.0,0.0], ...
[0.5019607843137255,0.5019607843137255,0.0], [0.0,0.5019607843137255,0.0], ...
[0.5019607843137255,0.0,0.5019607843137255], [0.0,0.5019607843137255,0.5019607843137255], ...
[0.0,0.0,0.5019607843137255], [1.0,1.0,0.0]};
% Transpose the next_stable_builds cell to plot them correctly
stable_builds_results = [];
dev_builds_results = [];
for index = 1 : length( next_stable_builds )
current_cell = next_stable_builds{index};
for cell_index = 1 : length( current_cell )
result = next_stable_builds{index}(cell_index);
if result > 360
result = 360.0;
end
if result < 0
result = 0.0;
end
stable_builds_results{cell_index}(index) = result;
end
end
for index = 1 : length( next_dev_builds )
current_cell = next_dev_builds{index};
for cell_index = 1 : length( current_cell )
result = next_dev_builds{index}(cell_index);
if result > 360
result = 360.0;
end
if result < 0
result = 0.0;
end
dev_builds_results{cell_index}(index) = result;
end
end
x_axis = 1:1:length(stable_builds_results{1});
for index = 1 : length( next_extected_builds )
linecolor = colors_for_the_grath{index};
expected_result = stable_builds_results{index};
next_extected_build = next_extected_builds(index);
legends{end+1} = [sprintf('Stable Build %g', next_extected_build)];
plot( x_axis, expected_result, '*', 'Color', linecolor );
legends{end+1} = [sprintf('Line', next_extected_build)];
plot( x_axis, expected_result, 'Color', linecolor, 'LineWidth', linewidth_small );
stable_polyfit = polyfit( x_axis, expected_result, index );
stable_mean = polyval( stable_polyfit, x_axis );
legends{end+1} = [sprintf('Mean', next_extected_build)];
plot( x_axis, stable_mean, 'Color', linecolor, 'LineWidth', linewidth );
end
last_index=index;
x_axis = 1:1:length(dev_builds_results{1});
for index = 1 : length( next_extected_builds )
linecolor = colors_for_the_grath{index+last_index};
expected_result = dev_builds_results{index};
next_extected_build = next_extected_builds(index);
legends{end+1} = [sprintf('Dev Build %g', next_extected_build)];
plot( x_axis, expected_result, '*', 'Color', linecolor );
legends{end+1} = [sprintf('Line', next_extected_build)];
plot( x_axis, expected_result, 'Color', linecolor, 'LineWidth', linewidth_small );
stable_polyfit = polyfit( x_axis, expected_result, index );
stable_mean = polyval( stable_polyfit, x_axis );
legends{end+1} = [sprintf('Mean', next_extected_build)];
plot( x_axis, stable_mean, 'Color', linecolor, 'LineWidth', linewidth );
end
xlabel( 'Simulations' );
ylabel( 'Days Between Releases' );
legend( legends, 'location', 'Best' );
grid on;
hold off;
% Plot the best visual graph
figure(2);
hold all;
stable_degree = 2;
dev_degree = 6;
stable_polyfit = polyfit( x_stable, y_stable, stable_degree );
stable_mean = polyval( stable_polyfit, x_stable );
dev_polyfit = polyfit( x_dev, y_dev, dev_degree );
dev_mean = polyval( dev_polyfit, x_dev );
linewidth = 2.0;
linewidth_small = 0.3;
legends = [];
linecolor = [0.0, 0.0,0.9];
legends{end+1} = ['Stable Points'];
plot( x_stable, y_stable, '*', 'Color', linecolor );
legends{end+1} = ['Stable Line'];
plot( x_stable, y_stable, 'Color', linecolor, 'LineWidth', linewidth_small );
legends{end+1} = ['Stable Mean'];
plot( x_stable, stable_mean, 'Color', linecolor, 'LineWidth', linewidth );
linecolor = [0.9, 0.0,0.0];
legends{end+1} = ['Development Points'];
plot( x_dev, y_dev, '*', 'Color', linecolor );
legends{end+1} = ['Development Line'];
plot( x_dev, y_dev, 'Color', linecolor, 'LineWidth', linewidth_small );
legends{end+1} = ['Development Mean'];
plot( x_dev, dev_mean, 'Color', linecolor, 'LineWidth', linewidth );
xlabel( 'Build Number' );
ylabel( 'Days Between Releases' );
legend( legends,'location','Best' );
grid on;
hold off;
@evandrocoan
Copy link
Author

evandrocoan commented Apr 20, 2019

New simplified version for quick usage in other scenarios.

#!/usr/bin/env octave

%{
# Licensing
#
# Graphics
# Copyright (C) 2018 Evandro Coan <https://github.com/evandrocoan>
#
# OS ARQUIVOS NESTE REPOSITÓRIO SÃO FORNECIDOS "NO ESTADO EM QUE SE ENCONTRAM", SEM GARANTIA DE
# QUALQUER TIPO, EXPRESSA OU IMPLÍCITA, INCLUINDO, MAS NÃO SE LIMITANDO ÀS GARANTIAS DE
# COMERCIALIZAÇÃO, APTIDÃO PARA UM PROPÓSITO ESPECÍFICO E NÃO INFRACÇÃO. EM NENHUMA CIRCUNSTÂNCIA, OS
# AUTORES OU TITULARES DE DIREITOS AUTORAIS SERÃO RESPONSÁVEIS POR QUALQUER RECLAMAÇÃO, DANOS OU OUTRA
# RESPONSABILIDADE, SEJA EM AÇÃO DE CONTRATO, DELITO OU DE OUTRA FORMA, DECORRENTE, DESTE OU
# RELACIONADO COM DOS ARQUIVOS DESTE REPOSITÓRIO OU O USO OU OUTRAS NEGOCIAÇÕES NO MODELO E SOFTWARE.
#
%}

clc
clear

close all
format long
fprintf( 1, 'Starting...\n' )

% warning on verbose
warning('off', 'MATLAB:polyfit:PolyNotUnique')
warning('off', 'MATLAB:polyfit:RepeatedPointsOrRescale')

x_stable = [3007, 3008, 3009, 3010, 3011, 3012, 3019, 3021, 3033, 3047, 3059, 3065, 3080, 3083, 3103, 3114, 3124, 3126, 3143];
y_stable = [1, 0, 2, 2, 6, 1, 30, 2, 54, 51, 173, 253, 209, 2, 320, 93, 133, 1, 355];

next_stable_builds = [];

% Creates nth polynoms to approximate the the next build release date
next_extected_builds = [3157, 3358, 3359, 3360];

for index = 1 : 10
    stable_polyfit = polyfit( x_stable, y_stable, index );
    stable_mean = polyval( stable_polyfit, x_stable );

    next_stable_builds{end+1} = polyval( stable_polyfit, next_extected_builds );
end

% Print the polynoms results to the standard output stream
fprintf( 1, 'next_stable_builds: \n   ' )
fprintf( 1, '%10g ', next_extected_builds )
fprintf( 1, '\n' )

for index = 1 : length( next_stable_builds )
    fprintf( 1, '%02d. ', index )
    fprintf( 1, '%10g ', next_stable_builds{index} )
    fprintf( 1, '\n' )
end



% Plot the polynoms as graphs
% https://stackoverflow.com/questions/607751/how-can-i-set-the-window-size-of-a-plot-window
figure( 1, 'position', [0,0,800,600] );
% figure( 1, "position", get(0, "screensize") )
hold all;

legends = [];
linewidth_tick = 2.0;
linewidth_small = 0.1;

colors = {...
    [0.0,0.0,0.0], ...
    [1.0,0.0,0.0], ...
    [0.0,1.0,0.0], ...
    [0.0,0.0,1.0], ...
    [0.0,1.0,1.0], ...
    [1.0,0.0,1.0], ...
    [0.7529411764705882,0.7529411764705882,0.7529411764705882], ...
    [0.5019607843137255,0.5019607843137255,0.5019607843137255], ...
    [0.5019607843137255,0.0,0.0], ...
    [0.5019607843137255,0.5019607843137255,0.0], ...
    [0.0,0.5019607843137255,0.0], ...
    [0.5019607843137255,0.0,0.5019607843137255], ...
    [0.0,0.5019607843137255,0.5019607843137255], ...
    [0.0,0.0,0.5019607843137255], ...
    [1.0,1.0,0.0] ...
};

% Transpose the next_stable_builds cell to plot them correctly
function stable_builds_results = transpose_to_plot(next_stable_builds)
    stable_builds_results = [];

    for index = 1 : length( next_stable_builds )
        current_cell = next_stable_builds{index};

        for cell_index = 1 : length( current_cell )
            result = next_stable_builds{index}(cell_index);

            if result > 360
                result = 360.0;
            end

            if result < 0
                result = 0.0;
            end

            stable_builds_results{cell_index}(index) = result;
        end
    end
end


stable_builds_results = transpose_to_plot(next_stable_builds);

% Programatically create several lines and add them to the graph for plotting
x_axis = 1:1:length(stable_builds_results{1});

for index = 1 : length( next_extected_builds )
    linecolor = colors{index};

    expected_result = stable_builds_results{index};
    next_extected_build = next_extected_builds(index);

    legends{end+1} = [sprintf('Stable Build %g', next_extected_build)];
    plot( x_axis, expected_result, '*', 'Color', linecolor );

    legends{end+1} = [sprintf('Line', next_extected_build)];
    plot( x_axis, expected_result, 'Color', linecolor, 'LineWidth', linewidth_small );

    stable_polyfit = polyfit( x_axis, expected_result, index );
    stable_mean = polyval( stable_polyfit, x_axis );

    legends{end+1} = [sprintf('Mean', next_extected_build)];
    plot( x_axis, stable_mean, 'Color', linecolor, 'LineWidth', linewidth_tick );
end

xlabel( 'Simulations' );
ylabel( 'Days Between Releases' );
legend( legends, 'location', 'Best' );

% https://stackoverflow.com/questions/607751/how-can-i-set-the-window-size-of-a-plot-window
% print('filename.png', '-dpng', '-S4096,2048');
print('filename.png', '-dpng', '-S2048,1024');

grid on;
hold off;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment