0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 function sugr_plot_histogram_density(x,pdf,npar,A,B,C)
0014
0015
0016 N = length(x);
0017
0018
0019
0020 N_bin = floor(sqrt(N));
0021 [NN,r] = hist(x,N_bin);
0022
0023
0024 bar(r,NN)
0025
0026
0027
0028
0029 range = abs(r(N_bin)-r(1))*N_bin/(N_bin-1);
0030 switch npar
0031 case 0
0032 plot(r,N_bin*range*pdf(r),'-r','LineWidth',4);
0033 case 1
0034 plot(r,N_bin*range*pdf(r,A),'-r','LineWidth',4);
0035 case 2
0036 plot(r,N_bin*range*pdf(r,A,B),'-r','LineWidth',4);
0037 case 3
0038 plot(r,N_bin*range*pdf(r,A,B,C),'-r','LineWidth',4);
0039 end
0040 xlim([r(1),r(N_bin)]);
0041 ylim([0,max(NN)*1.1]);
0042 xlabel('x');ylabel('$\propto p_x(x)$')
0043 title(['Histogram of the sample with ',num2str(N_bin),' bins, overlayed with its probability density.'])
0044
0045
0046