clear all
close all
load('input/prepared/Fixacni_stabilita_131030_features');
%% Statistical analysis
% Inicializace promennych
p = length(priznaky);
meanD = [];
stdD = [];
minD = [];
maxD = [];
varD = [];
meanK = [];
stdK = [];
minK = [];
maxK = [];
varK = [];
medianK = [];
medianD = [];
priznak = cell(p,1);

for i = 1:p
dys = priznaky{i}.values(priznaky{i}.indexes{1});
con = priznaky{i}.values(priznaky{i}.indexes{2});

% Pruzkumova analyza - zakladni statistiky
meanD=[meanD mean(dys)];% Stredni hodnota
stdD=[stdD std(dys)]; % Standardni odchylka
varD=[varD var(dys)]; % Rozptyl
minD=[minD min(dys)]; % Minimum
maxD=[maxD max(dys)]; % Maximum
medianD = [medianD median(dys)]; %Median
meanK=[meanK mean(con)];% Stredni hodnota
stdK=[stdK std(con)]; % Standardni odchylka
varK=[varK var(con)]; % Rozptyl
minK=[minK min(con)]; % Minimum
maxK=[maxK max(con)]; % Maximum
medianK = [medianK median(con)]; %Median
priznak{i} = [priznaky{i}.name num2str(i)];
end

T_basics = table(priznak, meanD',meanK', medianD', medianK',...
    maxD',maxK',minD',minK',varD', varK',stdD', stdK');

writetable(T_basics, 'Basics.csv');


%% ANOVA
clear all
close all
load('input/prepared/Fixacni_stabilita_131030_features');
p = [];
l = [];
priznak = cell(16,1);
% Overeni homegenity rozptylu Levenuv Test
leven = [];
for j=1:16
X = priznaky{j}.values';
trida = priznaky{j}.class'+1;
X = [X trida];
Levenetest(X);
end
% Overeni normality dat
ld = [];
lc = [];
for k = 1:16
dys = priznaky{k}.values(priznaky{k}.indexes{1});
con = priznaky{k}.values(priznaky{k}.indexes{2});
[ld(k) pd] = lillietest(dys);
[lc(k) pc] = lillietest(con);
end

% Vystupem ANOVA je p-value pro nulovou hypotezu, ze means jsou stejnefor i = 1:r
for i = 1:16
priznak{i} = [priznaky{i}.name num2str(i)];
%[p,tbl,stats] = anova1(priznaky{i}.values, priznaky{i}.class);
p(i) = anova1(log(priznaky{i}.values+1), priznaky{i}.class);
%p(i) = anova1(priznaky{i}.values, priznaky{i}.class);
end
T_anova = table(p);
writetable(T_anova,'Anova.csv');