forked from fortran-lang/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stat_dev: addition of .md file for mean
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Descriptive statistics | ||
|
||
## Implemented | ||
|
||
* `mean` | ||
|
||
## MEAN - mean of array elements | ||
|
||
### Description | ||
|
||
Returns the mean of all the elements of *ARRAY*, or of the elements of *ARRAY* along dimension *DIM*. | ||
|
||
### Syntax | ||
|
||
RESULT = mean(*ARRAY*) | ||
|
||
RESULT = mean(*ARRAY*, *DIM*) | ||
|
||
### Arguments | ||
|
||
*ARRAY*: Must 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*. | ||
|
||
### 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 *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 | ||
|
||
```fortran | ||
program test | ||
use stdlib_experimental_stat, only: mean | ||
implicit none | ||
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. /) | ||
end program | ||
``` |