For example in statistics we learn that mean = E(x) of a function which is defined as

μ=∫baxf(x)dx

however in calculus we learn that

μ=1b−a∫baf(x)dx

What is the difference between the means in statistics and calculus and why don’t they give the same answer?

thank you

**Answer**

This seems to be based on confusion resulting from resemblance between the notations used in the two situations.

In probability and statistics, one learns that ∫∞−∞xf(x)dx is the mean, **NOT** of the function f, but of a random variable denoted (capital) X (whereas lower-case x is used in the integral) whose probability density function is f. This is the same as ∫baxf(x)dx in cases where the probability is 1 that the random variable X is between a and b. (The failure, in the posted question, to distinguish betweeen the lower-case x used in the integral and the capital X used in the expression E(X) is an error that can make it impossible to understand expressions like Pr(X≤x) and some other things.)

In calculus, the expression 1b−a∫baf(x)dx is the mean, **NOT** of any random variable X, but of the function f itself, on the interval [a,b].11

Notice that in probability, you necessarily have ∫baf(x)dx=1 and f(x)≥0, and the mean ∫baxf(x)dx is necessarily between a and b. But none of that applies to the calculus problem, since the quantity whose mean is found is on the f(x)-axis, not on the x-axis.

§§§

**Postscript:** Nine people including me have up-voted “Jack M”‘s comment, so just to satisfy that point of view I will add some things.

If f is the density function of the probability distribution of the random variable (capital) X, then the mean of g(X) (where g is some other function) is ∫∞−∞g(x)f(x)dx. Applying that to the situation in calculus, one can say that the density function of the **uniform distribution** on the interval [a,b] is 1/(b−a), so if X is a random variable with that distribution, then E(f(X))=∫baf(x)1b−adx. And a random variable X itself can be regarded as a function whose domain is a sample space Ω, with the probability measure P assigning probabilities to subsets of \Omega, and then you have \operatorname E(X) = \int_\Omega X(\omega)\, P(d\omega).

**Attribution***Source : Link , Question Author : Johnathon , Answer Author : Michael Hardy*