diff options
author | dhuard <dhuard@localhost> | 2010-08-30 17:24:57 +0000 |
---|---|---|
committer | dhuard <dhuard@localhost> | 2010-08-30 17:24:57 +0000 |
commit | 400a2a6739e0d67e2e7965ad7fa3695bebf8511d (patch) | |
tree | bf818700a252097a09f8f18e883c0e1f4cb4a430 /numpy/lib/function_base.py | |
parent | c663655a87cfb7e818ed9d6bdb287ef3b63c3b29 (diff) | |
download | numpy-400a2a6739e0d67e2e7965ad7fa3695bebf8511d.tar.gz |
added a warning concerning the buggy normalization in histogram with non-uniform bin widths
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 11 |
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 |