summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 0ef75b02a..292dbe41d 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -155,8 +155,10 @@ def histogram(a, bins=10, range=None, normed=False, weights=None):
mn -= 0.5
mx += 0.5
bins = linspace(mn, mx, bins+1, endpoint=True)
+ uniform = True
else:
bins = asarray(bins)
+ uniform = False
if (np.diff(bins) < 0).any():
raise AttributeError(
'bins must increase monotonically.')
@@ -191,7 +193,16 @@ def histogram(a, bins=10, range=None, normed=False, weights=None):
if normed:
db = array(np.diff(bins), float)
+ if not uniform:
+ warnings.warn("""
+ This release of NumPy fixes a normalization bug in histogram
+ function occuring with non-uniform bin widths. The returned
+ value is now a density: n / (N * bin width), where n is the
+ bin count and N the total number of points.
+ """)
return n/db/n.sum(), bins
+
+
else:
return n, bins