Lesson goal: A list of numbers: maximum, minimum, and average

Previous: Compute the r-value for a trendline | Home | Next: A list of numbers: Make a histogram (Part 1)

From time to time, we will be confronted with a long list of numbers that we'll have to deal with, meaning: "come to some conclusions about the numbers." What can we do?

In a past lesson you worked on finding the average of some numbers in a file, with subsequent lessons having you finding the maximum and minimum values in a file as well. Let's repeat these actions here, but for an array called data that contains about 2,000 numbers.

The average of the numbers requires the sum of all of the numbers, which is then divided by the total number of numbers in the array ($N$), as in average=$\Sigma x_i/N$, where $x_i$ is the $i^{th}$ data point in the array.

The maximum and minimum numbers can be found as follows: let's sort the data array using Lua's built in table.sort() function. The minimum number will now be the first element, and the maximum the last element.

Now you try. Finish the code, to compute the min, max, and avg values of the data.

Type your code here:


See your results here: