Skip to content

Commit

Permalink
stat_dev: addition of .md file for mean
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdp1 committed Jan 21, 2020
1 parent ad504e8 commit e64657c
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/stdlib_experimental_stat.md
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
```

0 comments on commit e64657c

Please sign in to comment.