Home > chronux > fly_track > FAnalyze > functions > ProbDist2D.m

# ProbDist2D

PROBDIST2D

## SYNOPSIS function [P bins] = ProbDist2D(x, nbins);

## DESCRIPTION ```PROBDIST2D
Usage: [P bins] = [P bins] = ProbDist2D(x, nbins);

This function calculates the discrete probability distribution for a
variable that is in a two dimensional phase space.  Because the variable
exists in a two dimensional phase space, we have to bin in x^2
(equivalent to dividing P by x). The function simply calculates a
normalized histogram using 'hist', so nbins can take any form that hist
can take, although it does not allow for all the other hist options.```

## CROSS-REFERENCE INFORMATION This function calls:
This function is called by:

## SOURCE CODE ```0001 function [P bins] = ProbDist2D(x, nbins);
0002
0003 %PROBDIST2D
0004 %   Usage: [P bins] = [P bins] = ProbDist2D(x, nbins);
0005 %
0006 % This function calculates the discrete probability distribution for a
0007 % variable that is in a two dimensional phase space.  Because the variable
0008 % exists in a two dimensional phase space, we have to bin in x^2
0009 % (equivalent to dividing P by x). The function simply calculates a
0010 % normalized histogram using 'hist', so nbins can take any form that hist
0011 % can take, although it does not allow for all the other hist options.
0012
0013 %Written by Dan Valente
0014 %September 2007
0015
0016 [H bins] = hist(x.^2, nbins);
0017 N = sum(sum(H));
0018 binsize = bins(3)-bins(2);
0019 P = H./(N*binsize);
0020
0021 %now transform bins back to the unsquared locations.  This is really only
0022 %for conviencence, by no means is it necessary.  If this line is commented
0023 %out, then the plot is simply P vs. x^2 instead of P vs. x
0024 bins = sqrt(bins);
0025
0026 return;```

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005