[SciPy-user] histogram q's
mcsefl
mcsefl at gmail.com
Fri Mar 6 18:20:13 EST 2009
Hi all,
Sorry to bother on the F-D bin size question. It was easier to code than I
thought because of the scoreatpercentile function. Even if scipy.stats
doesn't have it, here is my implementation:
from scipy.stats import
scoreatpercentile
from numpy import
sort
def
FDbinSize(X):
"""Calculates the Freedman-Diaconis bin size
for
a data set for use in making a
histogram
Arguments:
X: 1D Data
set
Returns:
h: F-D bin
size
"""
# First Calculate the interquartile
range
X =
sort(X)
upperQuartile =
scoreatpercentile(X,.75)
lowerQuartile =
scoreatpercentile(X,.25)
IQR = upperQuartile -
lowerQuartile
# Find the F-D bin
size
h =
2.*IQR/len(X)**(1./3.)
return h
-Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20090306/a5c17884/attachment.html>
More information about the SciPy-User
mailing list