correlation_coefficient Function

public function correlation_coefficient(x, y) result(cor)

Function to calculate the correlation coefficient between two real vectors

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout), dimension(:) :: x

Real arrays

real(kind=wp), intent(inout), dimension(:) :: y

Real arrays

Return Value real(kind=wp)

Real value with the correlation coefficient


Calls

proc~~correlation_coefficient~~CallsGraph proc~correlation_coefficient correlation_coefficient proc~mean mean proc~correlation_coefficient->proc~mean proc~std std proc~correlation_coefficient->proc~std float float proc~mean->float proc~variance variance proc~std->proc~variance proc~variance->proc~mean

Source Code

    function correlation_coefficient(x,y) result(cor)
!============================================================================================
!! Function to calculate the correlation coefficient between two real vectors
        real(kind=wp),dimension(:),intent(inout) :: x,y
!! Real arrays
        real(kind=wp) :: cor 
!! Real value with the correlation coefficient
        integer :: ndat
        real(kind=wp) :: cov
        !
        ndat=size(x);
        cov=(sum((x-mean(x))*(y-mean(y)))/dble(ndat));
        cor=cov/(std(x)*std(y));
    end function correlation_coefficient