Skip to content

Commit

Permalink
stat_dev: modifs following comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdp1 committed Jan 21, 2020
1 parent e64657c commit b1c481d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/stdlib_experimental_stat.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@

## MEAN - mean of array elements

### Description
### Description:

Returns the mean of all the elements of *ARRAY*, or of the elements of *ARRAY* along dimension *DIM*.
Returns the mean of all the elements of *array*, or of the elements of *array* along dimension *dim*.

### Syntax
### Syntax:

RESULT = mean(*ARRAY*)
RESULT = mean(*array*)

RESULT = mean(*ARRAY*, *DIM*)
RESULT = mean(*array*, *dim*)

### Arguments
### Arguments:

*ARRAY*: Must be an array of type INTEGER, or REAL.
*array*: Shall be an array of type INTEGER, or REAL.

*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*.
*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*.

### Return value
### Return value:

If *ARRAY* is of type REAL, the result is of the same type as ARRAY.
If *ARRAY* is of type INTEGER, the result is of type as *double precision*.
If *array* is of type REAL, the result is of the same type as array.
If *array* is of type INTEGER, the result is of type as *double precision*.

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.
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.

### Example
### Example:

```fortran
program test
use stdlib_experimental_stat, only: mean
implicit none
real :: x(1:6) = (/ 1., 2., 3., 4., 5., 6. /)
real :: x(1:6) = [ 1., 2., 3., 4., 5., 6. ]
print *, mean(x) !returns 21.
print *, mean( reshape(x, (/ 2, 3 /) )) !returns 21.
print *, mean( reshape(x, (/ 2, 3 /) ), 1) !returns (/ 3., 7., 11. /)
print *, mean( reshape(x, [ 2, 3 ] )) !returns 21.
print *, mean( reshape(x, [ 2, 3 ] ), 1) !returns [ 3., 7., 11. ]
end program
```

0 comments on commit b1c481d

Please sign in to comment.