Calculates the population covariance between two variables given in two vectors of any size with one dimension applying the following equation:
Where:
z = pcovariance(x,y)
Where:
x
and y
= vectors of rank 1 with real numbers.
See this example to use an array of
rank larger than 1.z
= real number of the same kind as x
and y
with the population covariance of x
and y
.The following program calculates the population covariance between two variables:
PROGRAM pcovarianceExample
USE FU_Statistics, ONLY: pcovariance
IMPLICIT NONE
REAL, DIMENSION(5) :: x = [1., 2., 3., 4., 5.]
REAL, DIMENSION(5) :: y = [6., 7., 8., 9., 10.]
WRITE(*,*) pcovariance(x, y)
END PROGRAM pcovarianceExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in), | DIMENSION(:) | :: | x |
Vector of real numbers with the values of the first variable. It can have any size and it must have one dimension. |
|
real(kind=sp), | intent(in), | DIMENSION(:) | :: | y |
Vector of real numbers with the values of the second variable. It can have any size and it must have one dimension. |
Real number with the population covariance between both variables.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | DIMENSION(:) | :: | x |
Vector of real numbers with the values of the first variable. It can have any size and it must have one dimension. |
|
real(kind=dp), | intent(in), | DIMENSION(:) | :: | y |
Vector of real numbers with the values of the second variable. It can have any size and it must have one dimension. |
Real number with the population covariance between both variables.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=qp), | intent(in), | DIMENSION(:) | :: | x |
Vector of real numbers with the values of the first variable. It can have any size and it must have one dimension. |
|
real(kind=qp), | intent(in), | DIMENSION(:) | :: | y |
Vector of real numbers with the values of the second variable. It can have any size and it must have one dimension. |
Real number with the population covariance between both variables.