The sum S of a list of n
numbers L_{1}, L_{2}, ... L_{n} is

S = L_{1} + L_{2} + ...
+ L_{n}

The average A of this list
is S/n or

A = (L_{1} + L_{2} +
... + L_{n})/n

The relationship between
these two values, sum S and average A, is described by

S = n*A

We usually think that the
sum S is more "basic", and that the average A is "derived"
from it. But this intuition can be misleading.

1. From
the computational point of view, algorithms for computing S and A are very
similar.

Computing a sum,

L_{1} → S;

For i = 2, n

S + L_{i} → S;

Computing an average,

L_{1} → A;

For i = 2, n

(1 -1/i)A + L_{i}/i → A;

As we see, we do not need
to know the value of S to compute A.

2. In applications,
averages are used more often than sums, and in many cases the values of A are
meaningful when values of S are not.

Consider three simple
examples,

(1) The average height A
of a group of people is a meaningful measure, but the sum S of their heights is
not.

(2) The average score S of
students on a test is measure that is often used, but the sum of their scores S
is not.

(3) The average monthly
temperatures T are often quoted. The sum S of temperatures measured during one
month is physically meaningless.

Notice that in all three
examples we did not mention n. In the first example n was the size of a group,
in the second example, the size of the student population, and in the third,
the number of measurements used in computing the average. This allows us to
formulate one conclusion: The average is
more useful than the sum because the average is not so dependent on the length
n of a list of numbers.

3. Estimating sums and
averages

Estimating averages is
easy. We only need to take a random sample of size k from the list of length n
and compute its average A'. How reliable
the estimate is depends on the probability that |A - A'| is "small". This probability doesn't depend on the length
n of the list, but on the size of the sample and the variance of the list,
which can also be estimated from the sample.

We do not have a better
method of estimating the sum S than estimating the average A', and using S' =
n*A' as an estimate of S.

So when we are estimating,
an estimate of the average comes first, and an estimate of the sum is computed
from it.

4. Averages of functions
and integrals of functions

Let's consider the
situation in which, instead of a list, we have a function f(x), where x ranges
over an interval [a, b] of real numbers.

We cannot compute the sum
of the values of f, because x takes on infinitely many values. But we can estimate the average of f(x) by
taking a random sample of k numbers, x_{1}, x_{2}, ..., x_{k}, between a and b, and computing their
average, A' = (x_{1} + x_{2} + ... + x_{k})/k.

In most practical
situations we know something about the function f. For example, we may know that f is
continuous, or that f is increasing, or that f is a polynomial of some given
degree. Such information allows us to improve our estimate A' of the average by
constructing a "smart" sample instead of a random one. Instead of choosing x_{1},
...x_{k} randomly, we utilize our
knowledge about the function to get the most information from the sample.

It often happens that when
we increase k, the values A' "converge" (get closer and closer) to
some value A. This value A is the "true" average of the function f(x)
when x varies from a to b.

When we have the average A
of the function f(x), where x varies from a to b, we
can define the "sum" S of the function f(x) using the length of the
interval, b - a, of the variable x, instead of the length n of the list.

S = (b - a)*A

Mathematicians use the
word "integral" instead of "sum" in this context, but the
symbol for integral is just an elongated capital S. There are many techniques
to compute integrals, but it is good to know that

The integral of f(x) relative to x,
when x change from a to b,

is nothing else but

(The average of values of the function
f(x) when x changes from a to b) times (b - a)

Task.

Use fnInt to
compute values of integrals for some simple functions, Y1, for x between a and b. In each
case, compute random samples of various sizes k taken from the interval [a, b],
using

a + rand(k)*(b-a),

and compute the average of Y1 on the sample. Multiply the averages by B-A, and compare
these values to the value of the integral.

Programs:

fnInt(Y1,X,A,B) ENTER | Integral |

mean(Y1(A+rand(K)(B-A))) ENTER | Average (mean is under LIST MATH) |

mean(Y1(A+rand(K)(B-A)))/(B-A) ENTER | Average*(B-A) |

Example.

Subject: volume of a
sphere

The volume V of a sphere
with radius R is V =4/3*π*R^{3} = 4.188790205*R^{3}.

From the unit Volumes of
simple solids (B.1), we know that fnInt(Y1,X,-R,R) gives the volume of a sphere with radius R, when
Y1=π(R^{2}-X^{2}). But we want to find its approximate volume
using average.

We store -1 in A, 1 in B,
1 in R, and 500 in K, and use the formula for Average*(B-A) given above. In Y1,
we put

Y1=π(R^{2}-X^{2})

Now,

mean(Y1(A+rand(K)(B-A)))(B-A)

gives 4.280377221

4.278991177

4.211113664

(You won't get exactly
what I got!)

For R = 1, I got the
following results for three trials for each value K in the table.

K: | t_{1 } |
t_{2 } |
t_{3 } |

10 | 3.432127997 | 4.265872861 | 4.012707003 |

50 | 4.261826572 | 4.306862004 | 4.121034437 |

250 | 4.147011239 | 4.372769244 | 4.104467137 |

Calculus Index