0.6.2-dev0
FORCES
FORtran lib for Comp. Env. Sys.
Loading...
Searching...
No Matches
mo_moment::correlation Interface Reference

Correlation between two vectors. More...

Public Member Functions

real(sp) function correlation_sp (x, y, mask)
 
real(dp) function correlation_dp (x, y, mask)
 

Detailed Description

Correlation between two vectors.

Calculates the correlation between two input vectors, i.e. the covariance divided by the standard deviations:

\[\langle x y\rangle = \sum_i\frac{(x_i-\bar x)(y_i-\bar y)}{N\sqrt{\mu_2(x)\mu_2(y)}}\]

If an optinal mask is given, the average is only over those locations that correspond to true values in the mask. \(x\) can be single or double precision. The result will have the same numerical precision.

Example

vec1 = (/ 1., 2, 3., -999., 5., 6. /)
vec2 = (/ 1.3, 2.7, 3.9, 5.1, 6., 8. /)
m   = correlation(vec1, vec2, mask=((vec1 >= 0.) .and. (vec2 >= 0.)))

See also example in pf_tests directory.

Parameters
[in]real(sp/dp) :: x(:)First 1D-array with input numbers.
[in]real(sp/dp) :: y(:)Second 1D-array with input numbers.
Return values
real(sp/dp) :: correlationCorrelation between \(x\) and \(y\).
Parameters
[in]logical, optional :: mask(:)1D-array of logical values with size(x). If present, only those locations in dat corresponding to the true values in mask are used.
Note
Input values must be floating points.
Author
Matthias Cuntz
Date
Nov 2011
Dec 2011
  • covariance as <(x-<x>)(y-<y>)> instead of <xy>-<x><y>

Definition at line 240 of file mo_moment.f90.

Member Function/Subroutine Documentation

◆ correlation_dp()

real(dp) function mo_moment::correlation::correlation_dp ( real(dp), dimension(:), intent(in)  x,
real(dp), dimension(:), intent(in)  y,
logical, dimension(:), intent(in), optional  mask 
)

Definition at line 890 of file mo_moment.f90.

◆ correlation_sp()

real(sp) function mo_moment::correlation::correlation_sp ( real(sp), dimension(:), intent(in)  x,
real(sp), dimension(:), intent(in)  y,
logical, dimension(:), intent(in), optional  mask 
)

Definition at line 925 of file mo_moment.f90.


The documentation for this interface was generated from the following file: