atompy.integral_sum#

atompy.integral_sum(bincenters, y_data, lower=-inf, upper=inf)[source]#

Get the integral of a histogram by summing the counts weighted by the binsize. The binsize needs to be constant.

Parameters:
bincentersarray_like

center of bins. All bins should have equal size, otherwise return doesn’t make sense

y_dataarray_like

corresponding data

lower, upperfloat

only calculate integral within these bounds, including edges

Returns:
integralfloat

The value of the intergral

Examples

::
>>> import numpy as np
>>> import atompy as ap
>>> x, y = np.linspace(0, 2, 5), np.linspace(0, 4, 5)**2
>>> x, y
>>> ap.integral_sum(x, y)
15.0