The Cake way to do this would probably be with a collection.
This assumes that you have the data all loaded, based on your comment about “receives an array”. It’s almost certain, however, that you’d be better off doing this with a database query that doesn’t need to load all that data into PHP. The query builder includes a function for averaging.