sum_intervals

sherpa.utils.sum_intervals(src, indx0, indx1)[source] [edit on github]

Sum up data within one or more pairs of indexes.

Parameters:
srcsequence of floats

The data to be summed.

indx0, indx1scalar or sequence of int

The pair of indexes over which to sum the src array. The sizes of indx0 and indx1 must match, and each element of indx1 must be at least as large as the corresponding element in indx0.

Returns:
valscalar or array

The sum of the src over the given interval ranges.

Notes

It is assumed that all indexes are valid. That is, they are in the range [0, length of src). This condition is not checked for.

Examples

>>> sum_intervals([1.1, 2.2, 3.3, 4.4], 1, 2)
5.5
>>> sum_intervals([1.1, -2.2, 3.3, 4.4], [1, 0], [3, 0])
array([ 5.5,  1.1])