// returns the average of the values in
// array A, which has length N
double average(double *A, int N)
{
  double total = 0;
  for(int i = 0; i < N; i++)
    total = total + A[i];
  return total / N;
}