Skip to content

2016-1: Statistics - Mean

Write a function that takes a numeric array as its right argument and returns the mean (average) of the array.

Examples:

     (your_function) 1 2 3 4 5 6
3.5
     (your_function) ⍬           ⍝ the average of an empty vector is 0 
0
     (your_function) 17          ⍝ your solution should work with a scalar argument
17 
     (your_function) 5 3⍴⍳15     ⍝ and average the columns of a matrix
7 8 9
     (your_function) 3 3 3⍴⍳15   ⍝ or the matrices of a 3D array etc.
5 6  7
8 9 10
6 7  8
your_function ←

Solutions

Video Thumbnail YouTube

Chat transcript Code on GitHub