Skip to content

Commit

Permalink
Novy pristup k vykreslovani tabulek. Ponekud zabalenejsi fce.
Browse files Browse the repository at this point in the history
  • Loading branch information
jankuc committed Feb 6, 2014
1 parent cefeb55 commit 4c9e7f9
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 5 deletions.
9 changes: 7 additions & 2 deletions drawRenyiDistsFromMakeTable.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
A = renyiTab(2:end-1,:);

nVars = size(A, 1);
plot(A-repmat(min(A), size(A,1),1));
%plot(A-repmat(min(A), size(A,1),1));

renNames = {'sqrt', 'rice', 'sturge', 'doane', 'scott','kernel'};
legend(renNames);
Expand All @@ -24,4 +24,9 @@
res(nVars-k+1,l) = find(indeces(:,l)==k);
end
end
res

res

median(res,2)
mean(res,2)

138 changes: 138 additions & 0 deletions make1table.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
function [table, result] = make1table(part, njets, typeOfData, vars, X1, w1, X2, w2)
% [table, res] = make1table(part, njets, vars, X1, w1, X2, w2)
%
%


particle{1} = 'ele';
particle{2} = 'muo';

data{1} = {'Train + Test vs. Yield', 'train',1,0};
data{2} = {'Train vs. Test', 'val',1,2};
data{3} = {'Train + Test vs. Data', 'train',1,3};
data{4} = {'Yield vs. Data', 'train', 0,3};

%% headr of table
kk = 1;
table = cell(24,24);
table{kk,1} = 'PARTICLE';
table{kk,2} = 'SETS';
table{kk,3} = 'NJETS';
table{kk,4} = 'VAR #';
table{kk,5} = 'VAR NAME';
table{kk,6} = 'H KS';
table{kk,7} = 'PVAL KS';
table{kk,8} = 'STAT KS';
table{kk,9} = 'H Cramer';
table{kk,10} = 'PVAL Cramer';
table{kk,11} = 'STAT Cramer';
histType = {'sqrt', 'rice', 'sturge', 'doane', 'scott'};
renType = [histType 'kernel'];
nRenType = length(renType); % # of histoggrams + kernel
colR = 12;
colRR = colR + nRenType; % first column of renyi ranks

for k = 1:2*length(renType)
table{kk,colR - 1 + k} = renType{mod(k-1,nRenType) + 1};
end

for v = vars
kk = kk + 1;
currVar = leptonJetVar(v);

%[XX1, ww1] = cropVarToHistInterval(X1(:,v),w1,v);
%[XX2, ww2] = cropVarToHistInterval(X2(:,v),w2,v);

% filter out NaNs
arenan1 = isnan(X1(:,v));
w1f = w1(~arenan1);
X1f = X1(~arenan1,v);
arenan2 = isnan(X2(:,v));
w2f = w2(~arenan2);
X2f = X2(~arenan2,v);

% filter out negative for Masses
if ismember(v,6:14)
areBelowZero1 = X1f < 0;
w1f = w1f(~areBelowZero1);
X1f = X1f(~areBelowZero1);
areBelowZero2 = X2f < 0;
w2f = w2f(~areBelowZero2);
X2f = X2f(~areBelowZero2);
else
areBelowZero1 = logical(zeros(size(w1f)));
areBelowZero2 = logical(zeros(size(w2f)));
end

[a, b] = currVar.histInterval(njets, part);

%% TESTS
alpha = 0.01;
testType = 'kolm-smirn';
[hypKS, pvalKS, statKS] = ...
test1DEquality(X1f, w1f, X2f, w2f, testType, alpha);

testType = 'cramer';
[hypC, pvalC, statC] = ...
test1DEquality(X1f, w1f, X2f, w2f, testType, alpha);

statR = cell(nRenType,1);

%% histogram
figure;
nbin = getHistogramNBin(X1f, 'doane');
[f1, x1] = histwc(X1f, w1f,nbin,a, b);
[f2, x2] = histwc(X2f, w2f,nbin,a, b);
f2 = [f2; zeros(length(f1) - length(f2),1)];
f1 = [f1; zeros(length(f2) - length(f1),1)];
figure;
bar(x1,[f1 f2], 0.9, 'LineStyle', 'none')
title(leptonJetVar(v).toString())

testType = 'renyi';
% histType = {'sqrt', 'rice', 'sturge', 'doane', 'scott'};
for r = 1:length(histType) ;
nbin = getHistogramNBin(X2f, histType{r});
renyiAlpha = 0.3;
[~, ~, statR{r}] = ...
test1DEquality(X1f, w1f, X2f, w2f, testType, renyiAlpha,'hist', nbin, a, b);
end
[~, ~, statR{nRenType}] = ...
test1DEquality(X1f, w1f, X2f, w2f, testType, renyiAlpha,'kernel', 300, a, b);


%% printout of the KS, CM
%lepton, dataSet, nJets, var, H, pVal, stat
%[k, l, njets, v, hyp, pval, stat]
table{kk,1} = particle{part};
table{kk,2} = data{typeOfData}{1};
table{kk,3} = njets;
table{kk,4} = v;
table{kk,5} = leptonJetVar(v).toString;
table{kk,6} = hypKS;
table{kk,7} = pvalKS;
table{kk,8} = statKS;
table{kk,9} = hypC;
table{kk,10} = pvalC;
table{kk,11} = statC;

%% Printout of Renyi dists.
for l = 1:nRenType;
table{kk,colR - 1 + l} = statR{l};
result(kk-1, l) = statR{l};
end

end

B = getRanksFromMin(result);
%meanRR = mean(B,2);
medianRR = median(B,2);

for k = 1:length(vars)
for l = 1:nRenType;
table{k+1, colRR - 1 + l} = B(k,l);
end
table{k+1 ,colRR + nRenType} = medianRR(k);
end


50 changes: 50 additions & 0 deletions makeMoreTables.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
function [tables, results] = makeMoreTables(particleIn, nJets, doData)
% function res = makeMoreTables(particleIn, njetsIn, doData)
%
% particleIn: 1 ... ele
% 2 ... muo
% njetsIn: 2,3,4
% doData:
% data{1} = {'Train + Test vs. Yield', 'train',1,0};
% data{2} = {'Train vs. Test', 'val',1,2};
% data{3} = {'Train + Test vs. Data', 'train',1,3};
% data{4} = {'Yield vs. Data', 'train', 0,3};

particle{1} = 'ele';
particle{2} = 'muo';

data{1} = {'Train + Test vs. Yield', 'train',1,0};
data{2} = {'Train vs. Test', 'val',1,2};
data{3} = {'Train + Test vs. Data', 'train',1,3};
data{4} = {'Yield vs. Data', 'train', 0,3};

%% Load Data
try leptonJetData = evalin( 'base', 'leptonJetData' );
catch
leptonJetData = leptonJetsMat2Ram();
assignin('base', 'leptonJetData', leptonJetData);
end

%% Cycle
for part = particleIn
for l = doData
for njets = nJets
[X1, w1] = getLeptonJetsRamData(particle{part}, 1:leptonJetType.numTypes,...
'njets', njets, data{l}{2}, data{l}{3});
[X2, w2] = getLeptonJetsRamData(particle{part}, 1:leptonJetType.numTypes,...
'njets', njets, data{l}{2}, data{l}{4});
%% vars
if strcmp(particle{part},'ele')
vars = 1:24;
else
vars = 1:23;
end
if njets == 2
vars = setdiff(vars,5);
end
[tables{part}{njets}{l} results{part}{njets}{l}] = make1table(part, njets, l, vars, X1, w1, X2, w2);
end
end
end


7 changes: 4 additions & 3 deletions makeTable.m
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,12 @@
%meanRR = mean(B,2);
medianRR = median(B,2);

for kk = 1:length(doneVars)
% for kkk = kk-length(doneVars)+1:kk
for kkk = 1:length(doneVars)
for ll = 1:nRenType;
res{kk+1,colRR - 1 + ll} = B(kk,ll);
res{kk -length(doneVars) + kkk,colRR - 1 + ll} = B(kkk,ll);
end
res{kk+1,colRR + nRenType} = medianRR(kk);
res{kk -length(doneVars) + kkk ,colRR + nRenType} = medianRR(kkk);
end


Expand Down

0 comments on commit 4c9e7f9

Please sign in to comment.