probDensity

PURPOSE ^

PROBDENSITY return probability density and xout for plot

SYNOPSIS ^

function [ probDens, xout ] = probDensity( y, nBins )

DESCRIPTION ^

 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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Thu 30-Jan-2014 00:00:07 by m2html © 2005