Next: , Previous: , Up: Internal Routines   [Contents][Index]


15.5.464 psum

psum(data, powers [, axes, class, /onedim, /vnormalize, /cnormalize, /single]

Returns a weighted sum of data. The weights are equal to the coordinates in the dimensions given in axes to the integer powers given in powers. powers and axes may be scalars or arrays and must have the same number of elements. If axes is not specified, then indgen(powers) is assumed. If class is defined, then it must contain a class number for each element of data and the results will be gathered for each class separately. Keyword /onedim indicates that data should be treated as a 1d array. Keyword /vnormalize forces normalization with the total of the values for each result, and keyword /cnormalize with the total of the coordinate weights for each results. Keyword /single returns a single (weighted) sum - if axis was not specified. All calculations are performed in double precision and the result has data type double.

If w = indgen(data, 0) then psum(data, n, 0) is equal to total(data*w^n,0), and psum(data, n, 1, /cnormalize is equal to total(data*w^n)/total(w^n).