Task[edit]
Write a program to find the mean (arithmetic average) of a numeric vector.

In case of a zero-length input, since the mean of an empty set of numbers is ill-defined, the program may choose to behave in any way it deems appropriate, though if the programming language has an established convention for conveying math errors or undefined values, it's preferable to follow it.

See also
Tasks for calculating statistical measures



in one go
moving (sliding window)
moving (cumulative)

Mean
Arithmetic

Statistics/Basic
Averages/Arithmetic mean
Averages/Pythagorean means


Averages/Simple moving average




Geometric

Averages/Pythagorean means




Harmonic

Averages/Pythagorean means




Quadratic

Averages/Root mean square




Circular

Averages/Mean angle
Averages/Mean time of day




Median

Averages/Median




Mode

Averages/Mode




Standard deviation

Statistics/Basic



Cumulative standard deviation






To run:
Start up.
Demonstrate finding the arithmetic mean.
Wait for the escape key.
Shut down.
 
An entry is a thing with a fraction.
A list is some entries.
A sum is a fraction.
A mean is a fraction.
 
To demonstrate finding the arithmetic mean:
Create an example list.
Write "A list: " then the example list on the console.
Find a mean of the example list.
Write "The list's mean: " then the mean on the console.
Destroy the example list.
 
To add a fraction to a list:
Allocate memory for an entry.
Put the fraction into the entry's fraction.
Append the entry to the list.
 
To create an example list:
Add 1/1 to the example list.
Add 2/1 to the example list.
Add 5-1/3 to the example list.
Add 7-1/2 to the example list.
 
To find a sum of a list:
Put 0 into the sum.
Get an entry from the list.
Loop.
If the entry is nil, exit.
Add the entry's fraction to the sum.
Put the entry's next into the entry.
Repeat.
 
To find a mean of a list:
Find a sum of the list.
Put the sum divided by the list's count into the mean.
 
To convert a list to a string:
Get an entry from the list.
Loop.
If the entry is nil, break.
Append the entry's fraction to the string.
If the entry's next is not nil, append ", " to the string.
Put the entry's next into the entry.
Repeat.