Why do we use integration to calculate the average of a function? What I think is that we need to sum up all the values on the curve and we can only do that by integration. Is that correct? 

Suppose we want
to get the average
of $f(x)$
for
$a \le x \le b$.
As a first estimate,
we might use
$A_2
=\dfrac{f(a)+f(b)}{2}
$.
Adding another point,
$A_3
=\dfrac{f(a)+f((a+b)/2)+f(b)}{3}
$.
If we use
$n$ points,
we get
$A_n
=\frac1{n}\sum_{k=0}^{n-1} f(a+k(b-a)/n)
$.
In the limit,
if it exists,
we get
$A
=\lim_{n \to \infty} A_n
=\lim_{n \to \infty} \frac1{n}\sum_{k=0}^{n-1} f(a+k(b-a)/n)
$.
If $f(x)$ is nicely behaved,
$\int_a^b f(x) dx
=\lim_{n \to \infty} I_n
$
where
$I_n
=\Delta\sum_{k=0}^{n-1} f(a+k\Delta)
$ and
$\Delta
=\Delta(a, b, n)
=\dfrac{b-a}{n}
$.
But,
$I_n
=\Delta\sum_{k=0}^{n-1} f(a+k\Delta)
=\dfrac{b-a}{n}\sum_{k=0}^{n-1} f(a+k\dfrac{b-a}{n})
=(b-a)A_n
$,
so
$A_n
=\dfrac1{b-a}I_n
$.
Taking the limit,
the average value
is the integral
divided by the
length of the interval.
