f_sts_scc_core Function

public pure function f_sts_scc_core(x, y) result(corr)

Computes Spearman rank correlation coefficient between x and y. Uses f_sts_pcc_core on ranks.

Arguments

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

x vector (assumed size array)

real(kind=wp), intent(in) :: y(:)

y vector (assumed size array)

Return Value real(kind=wp)

Spearman correlation coefficient


Calls

proc~~f_sts_scc_core~~CallsGraph proc~f_sts_scc_core f_sts_scc_core proc~f_sts_pcc_core f_sts_pcc_core proc~f_sts_scc_core->proc~f_sts_pcc_core proc~s_utl_rank s_utl_rank proc~f_sts_scc_core->proc~s_utl_rank proc~f_sts_cov_core f_sts_cov_core proc~f_sts_pcc_core->proc~f_sts_cov_core proc~f_sts_var_core f_sts_var_core proc~f_sts_pcc_core->proc~f_sts_var_core proc~f_sts_mean_core f_sts_mean_core proc~f_sts_cov_core->proc~f_sts_mean_core proc~f_sts_var_core->proc~f_sts_mean_core

Called by

proc~~f_sts_scc_core~~CalledByGraph proc~f_sts_scc_core f_sts_scc_core proc~f_sts_scc f_sts_scc proc~f_sts_scc->proc~f_sts_scc_core interface~fsml_scc fsml_scc interface~fsml_scc->proc~f_sts_scc

Source Code

pure function f_sts_scc_core(x, y) result(corr)

! ==== Description
!! Computes Spearman rank correlation coefficient between x and y.
!! Uses `f_sts_pcc_core` on ranks.

! ==== Declarations
  real(wp), intent(in)  :: x(:)  !! x vector (assumed size array)
  real(wp), intent(in)  :: y(:)  !! y vector (assumed size array)
  real(wp)              :: corr  !! Spearman correlation coefficient
  real(wp), allocatable :: rx(:) !! ranks of x
  real(wp), allocatable :: ry(:) !! ranks of y

! ==== Instructions

  ! rank both arrays (uses your existing s_utl_rank)
  ! rank arrays allocated in ranking
  call s_utl_rank(x, rx)
  call s_utl_rank(y, ry)

  ! Pearson correlation on ranks
  corr = f_sts_pcc_core(rx, ry)

  ! deallocate
  deallocate(rx)
  deallocate(ry)

end function f_sts_scc_core