-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_plots_number_mstd.m
86 lines (75 loc) · 2.25 KB
/
make_plots_number_mstd.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
clear all;
LINE_WIDTH = 3;
DOT_WIDTH = 10;
PLOT_TITLE_SIZE = 20;
PLOT_LABELS_SIZE = 18;
PLOT_VALUES_SIZE = 18;
PLOT_LEGEND_SIZE = 18;
PLOT_LEGEND_LOCATION = 'northwest';
file_name = 'data_fb.txt';
data_file = fopen(file_name, 'r');
data = fscanf(data_file, '%f', [10, Inf]);
fclose(data_file);
n = data(1, :);
%number of sets plot
figure('Position', [0 0 1920 1080]);
plot(n, data(8, :), '-o', ...
'LineWidth', LINE_WIDTH, ...
'MarkerSize', DOT_WIDTH);
title('Number of A sets where |A+A|>|A-A|', ...
'FontSize', PLOT_TITLE_SIZE);
xlabel('n', ...
'FontSize', PLOT_LABELS_SIZE);
ylabel('Number of A sets', ...
'FontSize', PLOT_LABELS_SIZE);
set(gca, 'FontSize', PLOT_VALUES_SIZE);
grid on;
grid minor;
%proportions plot
figure('Position', [0 0 1920 1080]);
plot(n, data(9, :), '-o', ...
'LineWidth', LINE_WIDTH, ...
'MarkerSize', DOT_WIDTH);
title('Proportion between the number of A sets where |A+A|>|A-A| and the total number of sets', ...
'FontSize', PLOT_TITLE_SIZE);
xlabel('n', ...
'FontSize', PLOT_LABELS_SIZE);
ylabel('Proportion ', ...
'FontSize', PLOT_LABELS_SIZE);
set(gca, 'FontSize', PLOT_VALUES_SIZE);
grid on;
grid minor;
%logarithm
log_funct = log2(data(8, :));
log_funct = log_funct(n >= 15);
n = n(n >= 15);
m = (log_funct(n == 32) - log_funct(n == 18))/(32 - 18);
b = 0;
approximation_funct = m*n + b;
for i = [-100: 0.01: 0]
new_estimation = m*n + i;
if sum(abs(new_estimation - log_funct)) < sum(abs(approximation_funct - log_funct))
approximation_funct = new_estimation;
b = i;
end
end
figure('Position', [0 0 1920 1080]);
plot(n, log_funct, '-o', ...
'LineWidth', LINE_WIDTH, ...
'MarkerSize', DOT_WIDTH);
hold on;
plot(n, approximation_funct, '-o', ...
'LineWidth', LINE_WIDTH, ...
'MarkerSize', DOT_WIDTH);
title('Logarithm of number of A sets where |A+A|>|A-A|', ...
'FontSize', PLOT_TITLE_SIZE);
xlabel('n', ...
'FontSize', PLOT_LABELS_SIZE);
ylabel('Number of A sets', ...
'FontSize', PLOT_LABELS_SIZE);
set(gca, 'FontSize', PLOT_VALUES_SIZE);
legend({'log_2(number of A sets)', sprintf('%d*n + (%d)', m, b)}, ...
'FontSize', PLOT_LEGEND_SIZE, ...
'Location', PLOT_LEGEND_LOCATION);
grid on;
grid minor;