Expected value and Integral
Among the simplest summary of quantitative data is the sample mean. Given a random variable, the corresponding concept is given a variety of names, the distributional mean, the expectation, or the expected value. We begin with the case of discrete random variables where this analogy is more apparent. The formula for continuous random variables is obtained by approximating with a discrete random and noticing that the formula for the expected value is a Riemann sum. Thus, expected values for continuous random variables are determined by computing an integral.
Riemann sum
A Riemann sum is an approximation of a region's area, obtained by adding up the areas of multiple simplified slices of the region. It is applied in calculus to formalize the method of exhaustion, used to determine the area of a region. This process yields the integral, which computes the value of the area exactly.
References:
https://www.math.arizona.edu/~jwatkins/h-expectedvalue.pdf
https://brilliant.org/wiki/riemann-sums/