File data_analysis/gaussianity/gaussianity_plots.m changed (mode: 100644) (index 09fbed6..508863e) |
1 |
1 |
function gaussianity_plots(trace, varargin) |
function gaussianity_plots(trace, varargin) |
|
2 |
|
% don't show figures while batch processing |
|
3 |
|
set(0,'DefaultFigureVisible','off') |
|
4 |
|
|
2 |
5 |
quadno = size(trace,2); |
quadno = size(trace,2); |
3 |
6 |
modeno = quadno/4; |
modeno = quadno/4; |
4 |
7 |
assert((modeno==round(modeno))&&(modeno>0)); |
assert((modeno==round(modeno))&&(modeno>0)); |
|
... |
... |
function gaussianity_plots(trace, varargin) |
9 |
12 |
|
|
10 |
13 |
normalize = true; |
normalize = true; |
11 |
14 |
export = false; |
export = false; |
|
15 |
|
visible = 'on'; |
12 |
16 |
titlestr = 'pulse quadratures'; % generic name for data |
titlestr = 'pulse quadratures'; % generic name for data |
13 |
17 |
for k=1:2:length(varargin) |
for k=1:2:length(varargin) |
14 |
18 |
switch varargin{k} |
switch varargin{k} |
|
... |
... |
function gaussianity_plots(trace, varargin) |
24 |
28 |
case {'export','Export','save','Save'} |
case {'export','Export','save','Save'} |
25 |
29 |
if ~(varargin{k+1}==false) |
if ~(varargin{k+1}==false) |
26 |
30 |
export = true; |
export = true; |
|
31 |
|
visible = 'off'; |
27 |
32 |
exportstr = varargin{k+1}; |
exportstr = varargin{k+1}; |
28 |
33 |
end |
end |
29 |
34 |
otherwise |
otherwise |
|
... |
... |
function gaussianity_plots(trace, varargin) |
48 |
53 |
getsubtrace = @(m)trace(:,getinds(m)); |
getsubtrace = @(m)trace(:,getinds(m)); |
49 |
54 |
|
|
50 |
55 |
if normalize |
if normalize |
51 |
|
normalizestr = [10, ' (divided by std. deviation)']; |
|
|
56 |
|
normalizestr = [10, ' (data has been divided by its std. deviation)']; |
52 |
57 |
else |
else |
53 |
58 |
normalizestr = ''; |
normalizestr = ''; |
54 |
59 |
end |
end |
55 |
|
histfig = figure; |
|
56 |
|
cdffig = figure; |
|
57 |
|
qqfig = figure; |
|
58 |
|
kdensfig = figure; |
|
|
60 |
|
histfig = figure('visible',visible); |
|
61 |
|
cdffig = figure('visible',visible); |
|
62 |
|
qqfig = figure('visible',visible); |
|
63 |
|
kdensfig = figure('visible',visible); |
59 |
64 |
|
|
60 |
65 |
postprocess = @(m){ title('');... |
postprocess = @(m){ title('');... |
61 |
66 |
ntitle([inset, 'Mode no. ',num2str(m),10,... |
ntitle([inset, 'Mode no. ',num2str(m),10,... |
|
... |
... |
function gaussianity_plots(trace, varargin) |
66 |
71 |
s = 0; |
s = 0; |
67 |
72 |
for m=modes |
for m=modes |
68 |
73 |
s = s + 1; |
s = s + 1; |
69 |
|
figure(histfig); subplot(subplotheight, subplotwidth, s); hold all |
|
|
74 |
|
change_current_figure(histfig); subplot(subplotheight, subplotwidth, s); hold all |
70 |
75 |
hist(getsubtrace(m),50); |
hist(getsubtrace(m),50); |
71 |
76 |
postprocess(m); |
postprocess(m); |
72 |
77 |
|
|
73 |
|
figure(cdffig); subplot(subplotheight, subplotwidth, s); hold all |
|
|
78 |
|
change_current_figure(cdffig); subplot(subplotheight, subplotwidth, s); hold all |
74 |
79 |
arrayfun(@(n)cdfplot(trace(:,n)), getinds(m)); |
arrayfun(@(n)cdfplot(trace(:,n)), getinds(m)); |
75 |
80 |
postprocess(m); |
postprocess(m); |
76 |
81 |
|
|
77 |
|
figure(kdensfig); subplot(subplotheight, subplotwidth, s); hold all |
|
|
82 |
|
change_current_figure(kdensfig); subplot(subplotheight, subplotwidth, s); hold all |
78 |
83 |
arrayfun(@(n)ksdensity(trace(:,n)), getinds(m)); |
arrayfun(@(n)ksdensity(trace(:,n)), getinds(m)); |
79 |
84 |
postprocess(m); |
postprocess(m); |
80 |
85 |
|
|
81 |
|
figure(qqfig); subplot(subplotheight, subplotwidth, s); hold all |
|
|
86 |
|
change_current_figure(qqfig); subplot(subplotheight, subplotwidth, s); hold all |
82 |
87 |
qqplot(getsubtrace(m)); |
qqplot(getsubtrace(m)); |
83 |
88 |
postprocess(m); |
postprocess(m); |
84 |
89 |
end |
end |
|
... |
... |
function gaussianity_plots(trace, varargin) |
87 |
92 |
mysuptitle = @(plotstr)suptitle([plotstr, suptitlestr],... |
mysuptitle = @(plotstr)suptitle([plotstr, suptitlestr],... |
88 |
93 |
'fontsize', 11,... |
'fontsize', 11,... |
89 |
94 |
'plotregion', 0.92); |
'plotregion', 0.92); |
90 |
|
figure(histfig); mysuptitle('Histogram'); |
|
91 |
|
figure(cdffig); mysuptitle('Empirical CDF'); |
|
92 |
|
figure(kdensfig); mysuptitle('Quantile-quantile plot'); |
|
93 |
|
figure(qqfig); mysuptitle('Kernel density estimate'); |
|
|
95 |
|
change_current_figure(histfig); mysuptitle('Histogram'); set(histfig, 'visible', visible) |
|
96 |
|
change_current_figure(cdffig); mysuptitle('Empirical CDF'); set(cdffig, 'visible', visible) |
|
97 |
|
change_current_figure(kdensfig); mysuptitle('Kernel density estimate'); set(kdensfig, 'visible', visible) |
|
98 |
|
change_current_figure(qqfig); mysuptitle('Quantile-quantile plot'); set(qqfig, 'visible', visible) |
94 |
99 |
|
|
95 |
100 |
if export |
if export |
96 |
101 |
% note: hist does not work with pdf export. |
% note: hist does not work with pdf export. |
|
... |
... |
end |
109 |
114 |
|
|
110 |
115 |
|
|
111 |
116 |
|
|
|
117 |
|
function change_current_figure(h) |
|
118 |
|
set(0,'CurrentFigure',h) |
|
119 |
|
end |