| 1 |
function [n,z] = histpdfg(seqdraws,binnum,titstr,xlabstr,ylabstr) |
| 2 |
% [n,z] = histpdfg(seqdraws,binnum,titstr,xlabstr,ylabstr) |
| 3 |
% Plot (if no nargout) and export (if nargout) pdf by scaling histogram |
| 4 |
% of an unsorted sequence of draws |
| 5 |
% |
| 6 |
% seqdraws: an unordered sequence of draws |
| 7 |
% binnum: the total number of bins in histogram, with 10 being a starting value |
| 8 |
% titstr: title string; if [], no title |
| 9 |
% xlabstr: xlabel string; if [], no xlab |
| 10 |
% ylabstr: ylabel string; if [], no ylab |
| 11 |
%-------- |
| 12 |
% n: a vector of the number of elements in each bin or container |
| 13 |
% z: a vector of the position of the center of the bin |
| 14 |
% plot p.d.f. graph if no nargout |
| 15 |
% |
| 16 |
% October 1998 Tao Zha |
| 17 |
% |
| 18 |
% Copyright (C) 1997-2012 Tao Zha |
| 19 |
% |
| 20 |
% This free software: you can redistribute it and/or modify |
| 21 |
% it under the terms of the GNU General Public License as published by |
| 22 |
% the Free Software Foundation, either version 3 of the License, or |
| 23 |
% (at your option) any later version. |
| 24 |
% |
| 25 |
% It is distributed in the hope that it will be useful, |
| 26 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 27 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 28 |
% GNU General Public License for more details. |
| 29 |
% |
| 30 |
% If you did not received a copy of the GNU General Public License |
| 31 |
% with this software, see <http://www.gnu.org/licenses/>. |
| 32 |
% |
| 33 |
|
| 34 |
if (nargin==2), titstr=[]; xlabstr=[]; ylabstr=[]; end |
| 35 |
|
| 36 |
[n,z,bw]=hist2(seqdraws,binnum); |
| 37 |
n=(n/length(seqdraws))/bw; % make it p.d.f. |
| 38 |
%bar(z,n) |
| 39 |
if nargout |
| 40 |
z=z'; |
| 41 |
n=n'; |
| 42 |
else |
| 43 |
%figure |
| 44 |
plot(z,n) |
| 45 |
title(titstr) |
| 46 |
xlabel(xlabstr) |
| 47 |
ylabel(ylabstr) |
| 48 |
end |