Package Scientific :: Package Statistics :: Module Histogram :: Class WeightedHistogram

[frames] | no frames]

# Class WeightedHistogram

    Histogram --+
                |
               WeightedHistogram

Weighted histogram in one variable

Constructor: WeightedHistogram(|data|, |weights|, |bins|, |range|=None)

Arguments:

In a weighted histogram, each point has a specific weight. If all weights are one, the result is equivalent to a standard histogram. 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

__init__(self, data, weights, nbins, range=None) |

addData(self, data, weights) Add values to the originally supplied data sequence. |

Inherited from `Histogram`: `__getitem__`, `__getslice__`, `__len__`, `getBinCounts`, `getBinIndices`, `normalize`, `normalizeArea`

Method Details

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

Parameters:
  - `data` (`Numeric.array`) - a sequence of data points
  - `weights` (`Numeric.array`) - a sequence of weights, same length as data
  - `nbins` (`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.
Overrides: Histogram.__init__

### addData(self, data, weights)

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
Overrides: Histogram.addData

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