The problem is that you have some code that is not inside a function.
Either all your code needs to be inside functions (like setup()) and draw()), or you should not use functions at all (in which case your code is just a list of instructions).
Because you have a function (average()), you should put your draw code into draw():
Thank you TfGuy44! That works great! I did not understand that all code had to be in functions or not in any functions. I missed that somehow. Also thanks for the quick response. Now I understand.
er45