ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_sampleCor::setRho Interface Reference

Return the Spearman rank correlation matrix of the input (weighted) sample of shape (ndim, nsam) or (nsam, ndim) or the Spearman rank correlation coefficient a pair of (weighted) time series x(1:nsam) and y(1:nsam) where ndim is the number of data dimensions (the number of data attributes) and nsam is the number of data points.
More...

Detailed Description

Return the Spearman rank correlation matrix of the input (weighted) sample of shape (ndim, nsam) or (nsam, ndim) or the Spearman rank correlation coefficient a pair of (weighted) time series x(1:nsam) and y(1:nsam) where ndim is the number of data dimensions (the number of data attributes) and nsam is the number of data points.

This generic interface performs one of the following computational tasks:

  1. Compute the Spearman rank correlation coefficient corresponding to an input pair of time series x and y of nsam observations.
  2. Compute the Spearman rank correlation matrix corresponding to an input multivariate sample of nsam observations each with ndim attributes.

See the documentation of the parent module pm_sampleCor for algorithmic details and sample correlation matrix definition.

Parameters
[in,out]rho: The output or input/output positive semi-definite scalar or square matrix of shape (1 : ndim, 1 : ndim) of
  1. type real of default kind RK,
containing the (Spearman rank) correlation coefficient or matrix corresponding to the input sample or time series x and y, whichever is present.
  1. If x(:) and y(:) are present, then rho shall be a scalar.
  2. If sample is present, then rho shall be a square matrix of shape [size(sample, 3 - dim), size(sample, 3 - dim)].
    On output, only the specified input subset will be overwritten with the correlation matrix.
    Any elements not in the specified input subset remains intact.
[in]subset: The input scalar constant argument that can be any of the following:
  1. The constant lowDia, implying that only the lower-diagonal subset of the output correlation matrix must be computed.
    This option is available only if either of the input argument sample is present.
    By definition, all diagonal elements of rho will be set to 1.
  2. The constant uppDia, implying that only the upper-diagonal subset of the output correlation matrix must be computed.
    This option is available only if either of the input argument sample is present.
    By definition, all diagonal elements of rho will be set to 1.
This input argument is merely serves to resolve the different procedures of this generic interface from each other at compile-time.
[out]frankx: The output contiguous vector of shape (nsam) of the same type and kind as the output rho, containing the fractional ranking of the first attribute x of the observational sample, where nsam is the number of observations in the sample.
(optional. It must be present if and only if the input argument x is present)
[out]franky: The output contiguous vector of shape (nsam) of the same type and kind as the output rho, containing the fractional ranking of the second attribute x of the observational sample, where nsam is the number of observations in the sample.
(optional. It must be present if and only if the input argument y is present.)
[in]x: The input contiguous vector of shape (nsam) of,
  1. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU),
  2. type integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64),
  3. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
  4. type string container css_type,
  5. type string PDT container css_pdt,
or a scalar of,
  1. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of arbitrary length type parameter,
containing the first attribute x of the observational sample, where nsam is the number of observations in the sample.
(optional. It must be present if and only if the input argument y is present and rho and sample are missing.)
[in]y: The input contiguous vector of shape (nsam) of the same type and kind as the input x, containing the second attribute x of the observational sample, where nsam is the number of observations in the sample.
(optional. It must be present if and only if the input argument x is present and rho and sample are missing.)
[out]frank: The output contiguous array of the same type and kind as the output rho and of the same shape as the input sample, containing the fractional ranking of the sample attributes along the specified dim.
If sample is a matrix, then the input argument dim dictates the direction along which the correlation matrix rho must be computed (i.e., the direction of individual observations).
(optional. It must be present if and only if the input argument sample is present.)
[in]sample: The input contiguous array of shape (ndim, nsam) or (nsam, ndim) of,
  1. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU),
  2. type integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64),
  3. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
  4. type string container css_type,
  5. type string PDT container css_pdt,
or a scalar of,
  1. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of arbitrary length type parameter,
containing the sample comprised of nsam observations each with ndim attributes.
If sample is a matrix, then the input argument dim dictates the direction along which the correlation matrix rho must be computed (i.e., the direction of individual observations).
(optional. It must be present if and only if the input arguments rho, x, and y are missing.)
[in]dim: The input scalar integer of default kind IK indicating the dimension of sample along which the correlation matrix must be computed.
  1. If dim = 1, the input sample is assumed to have the shape (nsam, ndim).
  2. If dim = 2, the input sample is assumed to have the shape (ndim, nsam).
(optional. It must be present if and only if the input argument sample is present and is of rank 2.)
[in]weight: The input contiguous vector of length nsam,
  1. type integer of default kind IK,
  2. type real of default kind RK,
containing the corresponding weights of individual nsam observations in sample or the pair of vectors x and y.
(optional. default = getFilled(1, nsam).)


Possible calling interfaces

use pm_sampleCor, only: setRho
! XY time series Spearman rank correlation coefficient.
call setRho(rho, frankx(1:nsam), franky(1:nsam), x(1:nsam), y(1:nsam) ) ! Spearman rank correlation coefficient.
call setRho(rho, frankx(1:nsam), franky(1:nsam), x(1:nsam), y(1:nsam), weight(1:nsam)) ! Spearman rank correlation coefficient.
! sample Spearman rank correlation matrix.
call setRho(rho(1:ndim, 1:ndim), subset, sample(:,:), dim)
call setRho(rho(1:ndim, 1:ndim), subset, sample(:,:), dim, weight(1:nsam))
Return the Spearman rank correlation matrix of the input (weighted) sample of shape (ndim,...
This module contains classes and procedures for computing properties related to the correlation matri...
Warning
The condition any(x(1) /= x) must hold for the corresponding input arguments.
The condition any(y(1) /= x) must hold for the corresponding input arguments.
The input sample must contain at least two unique values per sample attribute.
The condition 0 < sum(weight) must hold for the corresponding input arguments.
The condition all(0. <= weight) must hold for the corresponding input arguments.
The condition 1 < size(sample, dim) must hold for the corresponding input arguments.
The condition size(frankx) == size(x) must hold for the corresponding input arguments.
The condition size(franky) == size(y) must hold for the corresponding input arguments.
The condition 0 < size(sample, 3 - dim) must hold for the corresponding input arguments.
The condition all(shape(frank) == shape(sample)) must hold for the corresponding input arguments.
The condition 1 <= dim .and. dim <= rank(sample) must hold for the corresponding input arguments.
The condition size(sample, 3 - dim) == size(variance) must hold for the corresponding input arguments.
The condition size(sample, 3 - dim) == size(mean) must hold for the corresponding input arguments.
The condition size(sample, dim) == size(weight) must hold for the corresponding input arguments.
The condition size(x) == size(weight) must hold for the corresponding input arguments.
The condition size(x) == size(y) must hold for the corresponding input arguments.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
See also
getCor
setCor
getRho
setRho
getCov
setCov
setECDF
getMean
setMean
getShifted
setShifted
getVar
setVar


Example usage

1program example
2
3 use pm_kind, only: SK, IK, LK, RK
4 use pm_io, only: display_type
5 use pm_distUnif, only: getUnifRand
7 use pm_distCov, only: getCovRand
8 use pm_arrayRange, only: getRange
9 use pm_sampleCor, only: setRho
10 use pm_sampleCor, only: uppDia
11 use pm_sampleCor, only: lowDia
12 use pm_sampleCor, only: upp
13 use pm_sampleCor, only: low
14 use pm_sampleMean, only: getMean
15 use pm_sampleMean, only: setMean
16 use pm_sampleShift, only: getShifted
17 use pm_arraySpace, only: getLinSpace
18 use pm_arrayResize, only: setResized
19 use pm_arrayFill, only: getFilled
20 use pm_io, only: getFormat
21
22 implicit none
23
24 type(display_type) :: disp
25 integer(IK) :: itry, ntry = 10
26 character(:), allocatable :: format
27 real(RK), allocatable :: rweight(:), rho(:,:), frank(:,:), frankt(:,:)
28 disp = display_type(file = "main.out.F90")
29
30 call disp%skip()
31 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
32 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
33 call disp%show("!Compute the Spearman correlation matrix for a pair of time series.")
34 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
35 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
36 call disp%skip()
37
38 block
39 use pm_kind, only: RKG => RKS ! All other real types are also supported.
40 integer(IK) :: ndim, nsam
41 real(RKG), allocatable :: sample(:,:)
42 format = getFormat(mold = [0._RKG], ed = SK_"es", signed = .true._LK)
43 call disp%show("ndim = 2; nsam = 10")
44 ndim = 2; nsam = 10
45 call disp%show("sample = reshape(getUnifRand(1, 20, ndim * nsam), shape = [ndim, nsam], order = [2, 1])")
46 sample = reshape(getUnifRand(1, 20, ndim * nsam), shape = [ndim, nsam], order = [2, 1])
47 call disp%show("sample")
48 call disp%show( sample , format = format )
49 call disp%show("call setResized(frank, shape(sample, IK))")
50 call setResized(frank, shape(sample, IK))
51 call disp%show("call setResized(frankt, getReversed(shape(sample, IK)))")
52 call setResized(frankt, getReversed(shape(sample, IK)))
53 call disp%show("rho = getFilled(0., ndim, ndim)")
54 rho = getFilled(0., ndim, ndim)
55 call disp%show("call setRho(rho, uppDia, frank, sample, dim = 2_IK)")
56 call setRho(rho, uppDia, frank, sample, dim = 2_IK)
57 call disp%show("rho")
58 call disp%show( rho , format = format )
59 call disp%skip()
60 call disp%show("rho = getFilled(0., ndim, ndim)")
61 rho = getFilled(0., ndim, ndim)
62 call disp%show("call setRho(rho, lowDia, frank, sample, dim = 2_IK)")
63 call setRho(rho, lowDia, frank, sample, dim = 2_IK)
64 call disp%show("rho")
65 call disp%show( rho , format = format )
66 call disp%show("frank")
67 call disp%show( frank , format = format )
68 call disp%skip()
69 call disp%show("Compute the sample correlation along the first dimension.", deliml = SK_'''')
70 call disp%skip()
71 call disp%show("rho = getFilled(0., ndim, ndim)")
72 rho = getFilled(0., ndim, ndim)
73 call disp%show("call setRho(rho, uppDia, frankt, transpose(sample), dim = 1_IK)")
74 call setRho(rho, uppDia, frankt, transpose(sample), dim = 1_IK)
75 call disp%show("rho")
76 call disp%show( rho , format = format )
77 call disp%show("frankt")
78 call disp%show( frankt , format = format )
79 call disp%skip()
80 call disp%show("rho = getFilled(0., ndim, ndim)")
81 rho = getFilled(0., ndim, ndim)
82 call disp%show("call setRho(rho, lowDia, frankt, transpose(sample), dim = 1_IK)")
83 call setRho(rho, lowDia, frankt, transpose(sample), dim = 1_IK)
84 call disp%show("rho")
85 call disp%show( rho , format = format )
86 call disp%show("frankt")
87 call disp%show( frankt , format = format )
88 call disp%skip()
89 call disp%show("Compute the full sample correlation for a pair of time series.", deliml = SK_'''')
90 call disp%skip()
91 call disp%show("call setRho(rho(1,1), frank(1,:), frank(2,:), sample(1,:), sample(2,:))")
92 call setRho(rho(1,1), frank(1,:), frank(2,:), sample(1,:), sample(2,:))
93 call disp%show("rho(1,1)")
94 call disp%show( rho(1,1) , format = format )
95 call disp%show("frank")
96 call disp%show( frank , format = format )
97 call disp%skip()
98 end block
99
100 call disp%skip()
101 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
102 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
103 call disp%show("!Compute the Spearman correlation matrix for a weighted pair of time series.")
104 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
105 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
106 call disp%skip()
107
108 block
109 use pm_arrayVerbose, only: getVerbose
110 use pm_kind, only: RKG => RKS ! All other real types are also supported.
111 integer(IK) :: ndim, nsam
112 integer(IK), allocatable :: iweight(:)
113 real(RKG), allocatable :: sample(:,:)
114 format = getFormat(mold = [0._RKG], ed = SK_"es", signed = .true._LK)
115 call disp%show("ndim = 2; nsam = 10")
116 ndim = 2; nsam = 10
117 call disp%show("sample = reshape(getUnifRand(1, 20, ndim * nsam), shape = [ndim, nsam], order = [2, 1])")
118 sample = reshape(getUnifRand(1, 20, ndim * nsam), shape = [ndim, nsam], order = [2, 1])
119 call disp%show("sample")
120 call disp%show( sample , format = format )
121 call disp%show("call setResized(frank, shape(sample, IK))")
122 call setResized(frank, shape(sample, IK))
123 call disp%show("call setResized(frankt, getReversed(shape(sample, IK)))")
124 call setResized(frankt, getReversed(shape(sample, IK)))
125 call disp%show("iweight = getUnifRand(1, 10, nsam) ! integer-valued weights.")
126 iweight = getUnifRand(1, 10, nsam) ! integer-valued weights.
127 call disp%show("iweight")
128 call disp%show( iweight )
129 call disp%show("rweight = iweight ! or real-valued weights.")
130 rweight = iweight ! or real-valued weights.
131 call disp%show("iweight")
132 call disp%show( iweight )
133
134 call disp%skip()
135 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
136 call disp%show("!Compute the correlation matrix with integer weights.")
137 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
138 call disp%skip()
139
140 call disp%show("rho = getFilled(0., ndim, ndim)")
141 rho = getFilled(0., ndim, ndim)
142 call disp%show("call setRho(rho, uppDia, frank, sample, 2_IK, iweight)")
143 call setRho(rho, uppDia, frank, sample, 2_IK, iweight)
144 call disp%show("rho")
145 call disp%show( rho , format = format )
146 call disp%show("frank")
147 call disp%show( frank , format = format )
148 call disp%skip()
149 call disp%show("rho = getFilled(0., ndim, ndim)")
150 rho = getFilled(0., ndim, ndim)
151 call disp%show("call setRho(rho, lowDia, frank, sample, 2_IK, iweight)")
152 call setRho(rho, lowDia, frank, sample, 2_IK, iweight)
153 call disp%show("rho")
154 call disp%show( rho , format = format )
155 call disp%show("frank")
156 call disp%show( frank , format = format )
157 call disp%skip()
158 call disp%show("Compute the sample correlation along the first dimension.", deliml = SK_'''')
159 call disp%skip()
160 call disp%show("rho = getFilled(0., ndim, ndim)")
161 rho = getFilled(0., ndim, ndim)
162 call disp%show("call setRho(rho, uppDia, frankt, transpose(sample), 1_IK, iweight)")
163 call setRho(rho, uppDia, frankt, transpose(sample), 1_IK, iweight)
164 call disp%show("rho")
165 call disp%show( rho , format = format )
166 call disp%skip()
167 call disp%show("rho = getFilled(0., ndim, ndim)")
168 rho = getFilled(0., ndim, ndim)
169 call disp%show("call setRho(rho, lowDia, frankt, transpose(sample), 1_IK, iweight)")
170 call setRho(rho, lowDia, frankt, transpose(sample), 1_IK, iweight)
171 call disp%show("rho")
172 call disp%show( rho , format = format )
173 call disp%show("frankt")
174 call disp%show( frankt , format = format )
175 call disp%skip()
176 call disp%show("Compute the full sample correlation for a pair of time series.", deliml = SK_'''')
177 call disp%skip()
178 call disp%show("call setRho(rho(1,1), frank(1,:), frank(2,:), sample(1,:), sample(2,:), iweight)")
179 call setRho(rho(1,1), frank(1,:), frank(2,:), sample(1,:), sample(2,:), iweight)
180 call disp%show("rho(1,1)")
181 call disp%show( rho(1,1) , format = format )
182 call disp%show("frank")
183 call disp%show( frank , format = format )
184 call disp%skip()
185
186 call disp%skip()
187 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
188 call disp%show("!Compute the correlation matrix with real weights.")
189 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
190 call disp%skip()
191
192 call disp%show("rho = getFilled(0., ndim, ndim)")
193 rho = getFilled(0., ndim, ndim)
194 call disp%show("call setRho(rho, uppDia, frank, sample, 2_IK, rweight)")
195 call setRho(rho, uppDia, frank, sample, 2_IK, rweight)
196 call disp%show("rho")
197 call disp%show( rho , format = format )
198 call disp%show("frank")
199 call disp%show( frank , format = format )
200 call disp%skip()
201 call disp%show("rho = getFilled(0., ndim, ndim)")
202 rho = getFilled(0., ndim, ndim)
203 call disp%show("call setRho(rho, lowDia, frank, sample, 2_IK, rweight)")
204 call setRho(rho, lowDia, frank, sample, 2_IK, rweight)
205 call disp%show("rho")
206 call disp%show( rho , format = format )
207 call disp%show("frank")
208 call disp%show( frank , format = format )
209 call disp%skip()
210 call disp%show("Compute the sample correlation along the first dimension.", deliml = SK_'''')
211 call disp%skip()
212 call disp%show("rho = getFilled(0., ndim, ndim)")
213 rho = getFilled(0., ndim, ndim)
214 call disp%show("call setRho(rho, uppDia, frankt, transpose(sample), 1_IK, rweight)")
215 call setRho(rho, uppDia, frankt, transpose(sample), 1_IK, rweight)
216 call disp%show("rho")
217 call disp%show( rho , format = format )
218 call disp%show("frankt")
219 call disp%show( frankt , format = format )
220 call disp%skip()
221 call disp%show("rho = getFilled(0., ndim, ndim)")
222 rho = getFilled(0., ndim, ndim)
223 call disp%show("call setRho(rho, lowDia, frankt, transpose(sample), 1_IK, rweight)")
224 call setRho(rho, lowDia, frankt, transpose(sample), 1_IK, rweight)
225 call disp%show("rho")
226 call disp%show( rho , format = format )
227 call disp%show("frankt")
228 call disp%show( frankt , format = format )
229 call disp%skip()
230 call disp%show("Compute the full sample correlation for a pair of time series.", deliml = SK_'''')
231 call disp%skip()
232 call disp%show("call setRho(rho(1,1), frank(1,:), frank(2,:), sample(1,:), sample(2,:), rweight)")
233 call setRho(rho(1,1), frank(1,:), frank(2,:), sample(1,:), sample(2,:), rweight)
234 call disp%show("rho(1,1)")
235 call disp%show( rho(1,1) , format = format )
236 call disp%show("frank")
237 call disp%show( frank , format = format )
238 call disp%skip()
239 end block
240
241end program example
Generate and return an array of the specified rank and shape of arbitrary intrinsic type and kind wit...
Generate minimally-spaced character, integer, real sequences or sequences at fixed intervals of size ...
Allocate or resize (shrink or expand) an input allocatable scalar string or array of rank 1....
Generate and return an output array whose elements are the reversed-order elements of the input array...
Generate count evenly spaced points over the interval [x1, x2] if x1 < x2, or [x2,...
Generate an equally-weighted (verbose or flattened) array of the input weighted array of rank 1 or 2.
Generate and return a random positive-definite (correlation or covariance) matrix using the Gram meth...
Definition: pm_distCov.F90:394
Generate and return a scalar or a contiguous array of rank 1 of length s1 of randomly uniformly distr...
Generate and return a generic or type/kind-specific IO format with the requested specifications that ...
Definition: pm_io.F90:18485
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
Generate and return the (weighted) mean of an input sample of nsam observations with ndim = 1 or 2 at...
Return the (weighted) mean of a pair of time series or of an input sample of nsam observations with n...
Generate a sample of shape (nsam), or (ndim, nsam) or (nsam, ndim) that is shifted by the specified i...
This module contains procedures and generic interfaces for convenient allocation and filling of array...
This module contains procedures and generic interfaces for generating ranges of discrete character,...
This module contains procedures and generic interfaces for resizing allocatable arrays of various typ...
This module contains procedures and generic interfaces for reversing the order of elements in arrays ...
This module contains procedures and generic interfaces for generating arrays with linear or logarithm...
This module contains procedures and generic interfaces for flattening (duplicating the elements of) a...
This module contains classes and procedures for generating random matrices distributed on the space o...
Definition: pm_distCov.F90:72
This module contains classes and procedures for computing various statistical quantities related to t...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
Definition: pm_kind.F90:543
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
Definition: pm_kind.F90:567
This module contains classes and procedures for computing the first moment (i.e., the statistical mea...
This module contains classes and procedures for shifting univariate or multivariate samples by arbitr...
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4!Compute the Spearman correlation matrix for a pair of time series.
5!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
8ndim = 2; nsam = 10
9sample = reshape(getUnifRand(1, 20, ndim * nsam), shape = [ndim, nsam], order = [2, 1])
10sample
11+1.400000E+01, +1.300000E+01, +7.000000E+00, +1.300000E+01, +1.900000E+01, +2.000000E+01, +1.300000E+01, +6.000000E+00, +1.000000E+01, +6.000000E+00
12+2.000000E+01, +1.200000E+01, +1.500000E+01, +5.000000E+00, +2.000000E+00, +3.000000E+00, +1.400000E+01, +4.000000E+00, +1.300000E+01, +1.300000E+01
13call setResized(frank, shape(sample, IK))
14call setResized(frankt, getReversed(shape(sample, IK)))
15rho = getFilled(0., ndim, ndim)
16call setRho(rho, uppDia, frank, sample, dim = 2_IK)
17rho
18+1.000000E+00, -2.994055E-01
19+0.000000E+00, +1.000000E+00
20
21rho = getFilled(0., ndim, ndim)
22call setRho(rho, lowDia, frank, sample, dim = 2_IK)
23rho
24+1.000000E+00, +0.000000E+00
25-2.994055E-01, +1.000000E+00
26frank
27+8.000000E+00, +6.000000E+00, +3.000000E+00, +6.000000E+00, +9.000000E+00, +1.000000E+01, +6.000000E+00, +1.500000E+00, +4.000000E+00, +1.500000E+00
28+1.000000E+01, +5.000000E+00, +9.000000E+00, +4.000000E+00, +1.000000E+00, +2.000000E+00, +8.000000E+00, +3.000000E+00, +6.500000E+00, +6.500000E+00
29
30'Compute the sample correlation along the first dimension.'
31
32rho = getFilled(0., ndim, ndim)
33call setRho(rho, uppDia, frankt, transpose(sample), dim = 1_IK)
34rho
35+1.000000E+00, -2.994055E-01
36+0.000000E+00, +1.000000E+00
37frankt
38+8.000000E+00, +1.000000E+01
39+6.000000E+00, +5.000000E+00
40+3.000000E+00, +9.000000E+00
41+6.000000E+00, +4.000000E+00
42+9.000000E+00, +1.000000E+00
43+1.000000E+01, +2.000000E+00
44+6.000000E+00, +8.000000E+00
45+1.500000E+00, +3.000000E+00
46+4.000000E+00, +6.500000E+00
47+1.500000E+00, +6.500000E+00
48
49rho = getFilled(0., ndim, ndim)
50call setRho(rho, lowDia, frankt, transpose(sample), dim = 1_IK)
51rho
52+1.000000E+00, +0.000000E+00
53-2.994055E-01, +1.000000E+00
54frankt
55+8.000000E+00, +1.000000E+01
56+6.000000E+00, +5.000000E+00
57+3.000000E+00, +9.000000E+00
58+6.000000E+00, +4.000000E+00
59+9.000000E+00, +1.000000E+00
60+1.000000E+01, +2.000000E+00
61+6.000000E+00, +8.000000E+00
62+1.500000E+00, +3.000000E+00
63+4.000000E+00, +6.500000E+00
64+1.500000E+00, +6.500000E+00
65
66'Compute the full sample correlation for a pair of time series.'
67
68call setRho(rho(1,1), frank(1,:), frank(2,:), sample(1,:), sample(2,:))
69rho(1,1)
70-2.994055E-01
71frank
72+8.000000E+00, +6.000000E+00, +3.000000E+00, +6.000000E+00, +9.000000E+00, +1.000000E+01, +6.000000E+00, +1.500000E+00, +4.000000E+00, +1.500000E+00
73+1.000000E+01, +5.000000E+00, +9.000000E+00, +4.000000E+00, +1.000000E+00, +2.000000E+00, +8.000000E+00, +3.000000E+00, +6.500000E+00, +6.500000E+00
74
75
76!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78!Compute the Spearman correlation matrix for a weighted pair of time series.
79!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81
82ndim = 2; nsam = 10
83sample = reshape(getUnifRand(1, 20, ndim * nsam), shape = [ndim, nsam], order = [2, 1])
84sample
85+2.000000E+01, +1.000000E+01, +1.100000E+01, +7.000000E+00, +1.800000E+01, +1.100000E+01, +1.300000E+01, +1.800000E+01, +7.000000E+00, +1.200000E+01
86+2.000000E+00, +7.000000E+00, +8.000000E+00, +1.700000E+01, +1.600000E+01, +3.000000E+00, +1.700000E+01, +1.400000E+01, +1.000000E+00, +4.000000E+00
87call setResized(frank, shape(sample, IK))
88call setResized(frankt, getReversed(shape(sample, IK)))
89iweight = getUnifRand(1, 10, nsam) ! integer-valued weights.
90iweight
91+9, +5, +7, +4, +2, +8, +9, +7, +8, +7
92rweight = iweight ! or real-valued weights.
93iweight
94+9, +5, +7, +4, +2, +8, +9, +7, +8, +7
95
96!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97!Compute the correlation matrix with integer weights.
98!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99
100rho = getFilled(0., ndim, ndim)
101call setRho(rho, uppDia, frank, sample, 2_IK, iweight)
102rho
103+1.000000E+00, +1.110473E-01
104+0.000000E+00, +1.000000E+00
105frank
106+1.000000E+01, +3.000000E+00, +4.500000E+00, +1.500000E+00, +8.500000E+00, +4.500000E+00, +7.000000E+00, +8.500000E+00, +1.500000E+00, +6.000000E+00
107+2.000000E+00, +5.000000E+00, +6.000000E+00, +9.500000E+00, +8.000000E+00, +3.000000E+00, +9.500000E+00, +7.000000E+00, +1.000000E+00, +4.000000E+00
108
109rho = getFilled(0., ndim, ndim)
110call setRho(rho, lowDia, frank, sample, 2_IK, iweight)
111rho
112+1.000000E+00, +0.000000E+00
113+1.110473E-01, +1.000000E+00
114frank
115+1.000000E+01, +3.000000E+00, +4.500000E+00, +1.500000E+00, +8.500000E+00, +4.500000E+00, +7.000000E+00, +8.500000E+00, +1.500000E+00, +6.000000E+00
116+2.000000E+00, +5.000000E+00, +6.000000E+00, +9.500000E+00, +8.000000E+00, +3.000000E+00, +9.500000E+00, +7.000000E+00, +1.000000E+00, +4.000000E+00
117
118'Compute the sample correlation along the first dimension.'
119
120rho = getFilled(0., ndim, ndim)
121call setRho(rho, uppDia, frankt, transpose(sample), 1_IK, iweight)
122rho
123+1.000000E+00, +1.110473E-01
124+0.000000E+00, +1.000000E+00
125
126rho = getFilled(0., ndim, ndim)
127call setRho(rho, lowDia, frankt, transpose(sample), 1_IK, iweight)
128rho
129+1.000000E+00, +0.000000E+00
130+1.110473E-01, +1.000000E+00
131frankt
132+1.000000E+01, +2.000000E+00
133+3.000000E+00, +5.000000E+00
134+4.500000E+00, +6.000000E+00
135+1.500000E+00, +9.500000E+00
136+8.500000E+00, +8.000000E+00
137+4.500000E+00, +3.000000E+00
138+7.000000E+00, +9.500000E+00
139+8.500000E+00, +7.000000E+00
140+1.500000E+00, +1.000000E+00
141+6.000000E+00, +4.000000E+00
142
143'Compute the full sample correlation for a pair of time series.'
144
145call setRho(rho(1,1), frank(1,:), frank(2,:), sample(1,:), sample(2,:), iweight)
146rho(1,1)
147+1.110473E-01
148frank
149+1.000000E+01, +3.000000E+00, +4.500000E+00, +1.500000E+00, +8.500000E+00, +4.500000E+00, +7.000000E+00, +8.500000E+00, +1.500000E+00, +6.000000E+00
150+2.000000E+00, +5.000000E+00, +6.000000E+00, +9.500000E+00, +8.000000E+00, +3.000000E+00, +9.500000E+00, +7.000000E+00, +1.000000E+00, +4.000000E+00
151
152
153!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
154!Compute the correlation matrix with real weights.
155!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156
157rho = getFilled(0., ndim, ndim)
158call setRho(rho, uppDia, frank, sample, 2_IK, rweight)
159rho
160+1.000000E+00, +1.110473E-01
161+0.000000E+00, +1.000000E+00
162frank
163+1.000000E+01, +3.000000E+00, +4.500000E+00, +1.500000E+00, +8.500000E+00, +4.500000E+00, +7.000000E+00, +8.500000E+00, +1.500000E+00, +6.000000E+00
164+2.000000E+00, +5.000000E+00, +6.000000E+00, +9.500000E+00, +8.000000E+00, +3.000000E+00, +9.500000E+00, +7.000000E+00, +1.000000E+00, +4.000000E+00
165
166rho = getFilled(0., ndim, ndim)
167call setRho(rho, lowDia, frank, sample, 2_IK, rweight)
168rho
169+1.000000E+00, +0.000000E+00
170+1.110473E-01, +1.000000E+00
171frank
172+1.000000E+01, +3.000000E+00, +4.500000E+00, +1.500000E+00, +8.500000E+00, +4.500000E+00, +7.000000E+00, +8.500000E+00, +1.500000E+00, +6.000000E+00
173+2.000000E+00, +5.000000E+00, +6.000000E+00, +9.500000E+00, +8.000000E+00, +3.000000E+00, +9.500000E+00, +7.000000E+00, +1.000000E+00, +4.000000E+00
174
175'Compute the sample correlation along the first dimension.'
176
177rho = getFilled(0., ndim, ndim)
178call setRho(rho, uppDia, frankt, transpose(sample), 1_IK, rweight)
179rho
180+1.000000E+00, +1.110473E-01
181+0.000000E+00, +1.000000E+00
182frankt
183+1.000000E+01, +2.000000E+00
184+3.000000E+00, +5.000000E+00
185+4.500000E+00, +6.000000E+00
186+1.500000E+00, +9.500000E+00
187+8.500000E+00, +8.000000E+00
188+4.500000E+00, +3.000000E+00
189+7.000000E+00, +9.500000E+00
190+8.500000E+00, +7.000000E+00
191+1.500000E+00, +1.000000E+00
192+6.000000E+00, +4.000000E+00
193
194rho = getFilled(0., ndim, ndim)
195call setRho(rho, lowDia, frankt, transpose(sample), 1_IK, rweight)
196rho
197+1.000000E+00, +0.000000E+00
198+1.110473E-01, +1.000000E+00
199frankt
200+1.000000E+01, +2.000000E+00
201+3.000000E+00, +5.000000E+00
202+4.500000E+00, +6.000000E+00
203+1.500000E+00, +9.500000E+00
204+8.500000E+00, +8.000000E+00
205+4.500000E+00, +3.000000E+00
206+7.000000E+00, +9.500000E+00
207+8.500000E+00, +7.000000E+00
208+1.500000E+00, +1.000000E+00
209+6.000000E+00, +4.000000E+00
210
211'Compute the full sample correlation for a pair of time series.'
212
213call setRho(rho(1,1), frank(1,:), frank(2,:), sample(1,:), sample(2,:), rweight)
214rho(1,1)
215+1.110473E-01
216frank
217+1.000000E+01, +3.000000E+00, +4.500000E+00, +1.500000E+00, +8.500000E+00, +4.500000E+00, +7.000000E+00, +8.500000E+00, +1.500000E+00, +6.000000E+00
218+2.000000E+00, +5.000000E+00, +6.000000E+00, +9.500000E+00, +8.000000E+00, +3.000000E+00, +9.500000E+00, +7.000000E+00, +1.000000E+00, +4.000000E+00
219
220
Test:
test_pm_sampleCor


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Fatemeh Bagheri, Monday 02:15 AM, September 27, 2021, Dallas, TX
Amir Shahmoradi, Monday March 6, 2017, 3:22 pm, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin.

Definition at line 9645 of file pm_sampleCor.F90.


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