Skip to content

Commit 7b1ebc7

Browse files
committed
covariance_dev: spec
1 parent 279a192 commit 7b1ebc7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/stdlib_experimental_stats.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
### Description
1212

13-
Returns the covariance of the elements of `array` along dimension `dim` if the corresponding element in `mask` is `true` (if `mask` is provided).
13+
Returns the covariance of the elements of `array` along dimension `dim` if the corresponding element in `mask` is `true`.
1414

1515
Per default, the covariance is defined as:
1616

1717
```
18-
cov(array) = 1/(n-1) sum_i (array(i) - mean(array) * (array(i) - mean(array)) )
18+
cov(array) = 1/(n-1) sum_i (array(i) - mean(array) * (array(i) - mean(array)))
1919
```
2020

2121
where n is the number of elements.
@@ -29,7 +29,7 @@ The scaling can be changed with the logical argument `corrected`. If `corrected`
2929

3030
### Arguments
3131

32-
`array`: Shall be a 1-rank or a 2-rank array of type `integer`, `real`, or `complex`.
32+
`array`: Shall be a rank-1 or a rank-2 array of type `integer`, `real`, or `complex`.
3333

3434
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to n, where n is the rank of `array`.
3535

@@ -39,14 +39,15 @@ The scaling can be changed with the logical argument `corrected`. If `corrected`
3939

4040
### Return value
4141

42-
If `array` is of rank 1 and of type `real` or `complex`, the result is of the same type `real` corresponding to the type of `array`.
42+
If `array` is of rank 1 and of type `real` or `complex`, the result is of type `real` corresponding to the type of `array`.
4343
If `array` is of rank 2 and of type `real` or `complex`, the result is of the same type as `array`.
4444
If `array` is of type `integer`, the result is of type `real(dp)`.
4545

4646
If `array` is of rank 1, a scalar with the covariance (that is the variance) of all elements in `array` is returned.
47-
If `array` is of rank 2, a 2-rank array is returned.
47+
If `array` is of rank 2, a rank-2 array is returned.
4848

4949
If `mask` is specified, the result is the covariance of all elements of `array` corresponding to `true` elements of `mask`. If every element of `mask` is `false`, the result is IEEE `NaN`.
50+
5051
### Example
5152

5253
```fortran

0 commit comments

Comments
 (0)