Computes covariance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (assumed size array) |
||
real(kind=wp), | intent(in) | :: | y(:) |
y vector (assumed size array) |
||
real(kind=wp), | intent(in) | :: | ddof |
delta degrees of freedom |
covariance
pure function f_sts_cov_core(x, y, ddof) result(cov) ! ==== Description !! Computes covariance. ! ==== Declarations real(wp), intent(in) :: x(:) !! x vector (assumed size array) real(wp), intent(in) :: y(:) !! y vector (assumed size array) real(wp), intent(in) :: ddof !! delta degrees of freedom real(wp) :: xbar !! mean of x real(wp) :: ybar !! mean of y real(wp) :: cov !! covariance ! ==== Instructions xbar = f_sts_mean_core(x) ybar = f_sts_mean_core(y) cov = dot_product( (x - xbar), (y - ybar) ) / & & (real(size(x), kind=wp) - ddof) end function f_sts_cov_core