|
6 | 6 |
|
7 | 7 | ## MEAN - mean of array elements
|
8 | 8 |
|
9 |
| -### Description |
| 9 | +### Description: |
10 | 10 |
|
11 |
| -Returns the mean of all the elements of *ARRAY*, or of the elements of *ARRAY* along dimension *DIM*. |
| 11 | +Returns the mean of all the elements of *array*, or of the elements of *array* along dimension *dim*. |
12 | 12 |
|
13 |
| -### Syntax |
| 13 | +### Syntax: |
14 | 14 |
|
15 |
| -RESULT = mean(*ARRAY*) |
| 15 | +RESULT = mean(*array*) |
16 | 16 |
|
17 |
| -RESULT = mean(*ARRAY*, *DIM*) |
| 17 | +RESULT = mean(*array*, *dim*) |
18 | 18 |
|
19 |
| -### Arguments |
| 19 | +### Arguments: |
20 | 20 |
|
21 |
| -*ARRAY*: Must be an array of type INTEGER, or REAL. |
| 21 | +*array*: Shall be an array of type INTEGER, or REAL. |
22 | 22 |
|
23 |
| -*DIM* (optional): Must be a scalar of type INTEGER with a value in the range from 1 to n, where n equals the rank of *ARRAY*. |
| 23 | +*dim* (optional): Shall be a scalar of type INTEGER with a value in the range from 1 to n, where n is the rank of *array*. |
24 | 24 |
|
25 |
| -### Return value |
| 25 | +### Return value: |
26 | 26 |
|
27 |
| -If *ARRAY* is of type REAL, the result is of the same type as ARRAY. |
28 |
| -If *ARRAY* is of type INTEGER, the result is of type as *double precision*. |
| 27 | +If *array* is of type REAL, the result is of the same type as array. |
| 28 | +If *array* is of type INTEGER, the result is of type as *double precision*. |
29 | 29 |
|
30 |
| -If *DIM* is absent, a scalar with the mean of all elements in *ARRAY* is returned. Otherwise, an array of rank n-1, where n equals the rank of *ARRAY*, and a shape similar to that of *ARRAY* with dimension *DIM* dropped is returned. |
| 30 | +If *dim* is absent, a scalar with the mean of all elements in *array* is returned. Otherwise, an array of rank n-1, where n equals the rank of *array*, and a shape similar to that of *array* with dimension *dim* dropped is returned. |
31 | 31 |
|
32 |
| -### Example |
| 32 | +### Example: |
33 | 33 |
|
34 | 34 | ```fortran
|
35 | 35 | program test
|
36 | 36 | use stdlib_experimental_stat, only: mean
|
37 | 37 | implicit none
|
38 |
| - real :: x(1:6) = (/ 1., 2., 3., 4., 5., 6. /) |
| 38 | + real :: x(1:6) = [ 1., 2., 3., 4., 5., 6. ] |
39 | 39 | print *, mean(x) !returns 21.
|
40 |
| - print *, mean( reshape(x, (/ 2, 3 /) )) !returns 21. |
41 |
| - print *, mean( reshape(x, (/ 2, 3 /) ), 1) !returns (/ 3., 7., 11. /) |
| 40 | + print *, mean( reshape(x, [ 2, 3 ] )) !returns 21. |
| 41 | + print *, mean( reshape(x, [ 2, 3 ] ), 1) !returns [ 3., 7., 11. ] |
42 | 42 | end program
|
43 | 43 | ```
|
0 commit comments