Package Scientific :: Package Statistics :: Module Histogram :: Class Histogram
[hide private]
[frames] | no frames]

Class Histogram



Known Subclasses:
WeightedHistogram

Histogram in one variable

The bin index and the number of points in a bin can be obtained by indexing the histogram with the bin number. Application of len() yields the number of bins. A histogram thus behaves like a sequence of bin index - bin count pairs.

Instance Methods [hide private]
  __getitem__(self, index)
Returns an array of shape (2,) containing the bin value and the bin count
  __getslice__(self, first, last)
  __init__(self, data, nbins, range=None)
int __len__(self)
Returns the number of bins
  _addData(self, data)
  _setup(self, data, nbins, range)
  addData(self, data)
Add values to the originally supplied data sequence.
  normalize(self, norm=1.0)
Scale all bin counts by the same factor
  normalizeArea(self, norm=1.0)
Scale all bin counts by the same factor

Method Details [hide private]

__getitem__(self, index)
(Indexing operator)

 
Parameters:
  • index (int) - a bin index
Returns:
an array of shape (2,) containing the bin value and the bin count

__getslice__(self, first, last)
(Slicling operator)

 

__init__(self, data, nbins, range=None)
(Constructor)

 
Parameters:
  • data (Numeric.array of float or int) - a sequence of data points
  • bins (int) - the number of bins into which the data is to be sorted
  • range (tuple or NoneType) - a tuple of two values, specifying the lower and the upper end of the interval spanned by the bins. Any data point outside this interval will be ignored. If no range is given, the smallest and largest data values are used to define the interval.

__len__(self)
(Length operator)

 
Returns: int
the number of bins

_addData(self, data)

 

_setup(self, data, nbins, range)

 

addData(self, data)

 

Add values to the originally supplied data sequence. Use this method to feed long data sequences in multiple parts to avoid memory shortages.
Parameters:
  • data (Numeric.array) - a sequence of data points

Note: this does not affect the default range of the histogram, which is fixed when the histogram is created.

normalize(self, norm=1.0)

 

Scale all bin counts by the same factor
Parameters:
  • norm (float or int) - the sum of all bin counts after the rescaling

normalizeArea(self, norm=1.0)

 

Scale all bin counts by the same factor
Parameters:
  • norm (float or int) - the area under the histogram after the rescaling