@@ -5420,9 +5420,9 @@ def hist(self, x, bins=10, normed=False, cumulative=False,
5420
5420
bottom = None , histtype = 'bar' , align = 'edge' ,
5421
5421
orientation = 'vertical' , width = None , log = False , ** kwargs ):
5422
5422
"""
5423
- HIST(x, bins=10, normed=False, bottom=None, histtype='bar' ,
5424
- align='edge', orientation='vertical ', width=None ,
5425
- log=False, **kwargs)
5423
+ HIST(x, bins=10, normed=False, cumulative=False ,
5424
+ bottom=None, histtype='bar ', align='edge' ,
5425
+ orientation='vertical', width=None, log=False, **kwargs)
5426
5426
5427
5427
Compute the histogram of x. bins is either an integer number of
5428
5428
bins or a sequence giving the bins. x are the data to be binned.
@@ -5437,13 +5437,13 @@ def hist(self, x, bins=10, normed=False, cumulative=False,
5437
5437
5438
5438
# trapezoidal integration of the probability density function
5439
5439
pdf, bins, patches = ax.hist(...)
5440
- print np.trapz (pdf, bins)
5440
+ print np.sum (pdf * np.diff( bins) )
5441
5441
5442
- If cumulative is True then histogram is computed where each bin
5442
+ If cumulative is True then a histogram is computed where each bin
5443
5443
gives the counts in that bin plus all bins for smaller values.
5444
5444
The last bins gives the total number of datapoints. If normed is
5445
5445
also True then the histogram is normalized such that the last bin
5446
- equals one (assuming equally spaced bins) .
5446
+ equals one.
5447
5447
5448
5448
histtype = 'bar' | 'step'. The type of histogram to draw.
5449
5449
'bar' is a traditional bar-type histogram, 'step' generates
@@ -5469,10 +5469,10 @@ def hist(self, x, bins=10, normed=False, cumulative=False,
5469
5469
normed = bool (normed ), new = True )
5470
5470
5471
5471
if cumulative :
5472
- n = n .cumsum ()
5473
5472
if normed :
5474
- # normalize to 1
5475
- n *= (bins [1 ]- bins [0 ])
5473
+ n = (n * np .diff (bins )).cumsum ()
5474
+ else :
5475
+ n = n .cumsum ()
5476
5476
5477
5477
if histtype == 'bar' :
5478
5478
if width is None :
0 commit comments