PROBDENSITY return probability density and xout for plot [ probDens, xout ] = probDensity( y, nBins ) probDensity() compute probability density of y in each bin and return xout as center of each bin.
0001 function [ probDens, xout ] = probDensity( y, nBins ) 0002 % PROBDENSITY return probability density and xout for plot 0003 % 0004 % [ probDens, xout ] = probDensity( y, nBins ) 0005 % probDensity() compute probability density of y in each bin and return xout 0006 % as center of each bin. 0007 0008 % --------- 0009 % Yen-Nan Lin, NTHU, 2010-2014, Matlab 2012a 0010 0011 binSize = (max(y(:)) - min(y(:))) / nBins; 0012 nElement = numel(y); 0013 [count, xout] = hist(y(:), nBins); 0014 prob = count / nElement; 0015 probDens = prob / binSize; 0016 end