Skip to content

Commit e64657c

Browse files
committed
stat_dev: addition of .md file for mean
1 parent ad504e8 commit e64657c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/stdlib_experimental_stat.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Descriptive statistics
2+
3+
## Implemented
4+
5+
* `mean`
6+
7+
## MEAN - mean of array elements
8+
9+
### Description
10+
11+
Returns the mean of all the elements of *ARRAY*, or of the elements of *ARRAY* along dimension *DIM*.
12+
13+
### Syntax
14+
15+
RESULT = mean(*ARRAY*)
16+
17+
RESULT = mean(*ARRAY*, *DIM*)
18+
19+
### Arguments
20+
21+
*ARRAY*: Must be an array of type INTEGER, or REAL.
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*.
24+
25+
### Return value
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*.
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.
31+
32+
### Example
33+
34+
```fortran
35+
program test
36+
use stdlib_experimental_stat, only: mean
37+
implicit none
38+
real :: x(1:6) = (/ 1., 2., 3., 4., 5., 6. /)
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. /)
42+
end program
43+
```

0 commit comments

Comments
 (0)