Generate and return the integrated auto-correlation time (ACT) of the discrete signal.
More...
Generate and return the integrated auto-correlation time (ACT) of the discrete signal.
This generic interface a flexible wrapper for the lower-level potentially faster generic interface setACF.
See the documentation of the parent module pm_sampleACT for algorithmic details and auto-correlation definition.
- Parameters
-
[in] | seq | : The input contiguous vector of arbitrary size (of minimum 2 ) of,
-
type
real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the sequence auto-correlation time must be computed.
|
[in] | weight | : The input vector of type integer of default kind IK of the same size as the input seq , containing the weights of the corresponding elements of the input seq .
(optional, default = [(1, i = 1, size(seq))] ) |
[in] | method | : The input scalar constant that can be:
-
the constant batchMeans or an object of type batchMeans_type(size = size), implying that the returned ACT is computed using the BatchMeans method with the optionally specified
size .
If the size component of the input object of type batchMeans_type(size = size) is unset or 0 , an appropriate default based on the length of the input sequence will be determined and used.
This option offers a reasonable tradeoff between good estimate and computational efficiency.
However, the results depend heavily on the specified batch size, hence, still underestimate the actual ACT.
-
the constant batchMeansMax or an object of type batchMeans_type(smin, smax, step), implying that the returned ACT is computed as the maximum of the BatchMeans method for the specified range of batch sizes `getRange(batchMeans_type%smin, batchMeans_type%smax, batchMeans_type%step).
If the components of the input object of type batchMeans_type(smin, smax, step) are unset (default), then smin and step will be both set to 1 and smax is set to size(seq) / 2 .
This option will likely yield the least biased results but will be computationally significantly more demanding.
-
the constant cumSum or an object of type cumSum_type(signif), implying that the returned ACT is simply the cumulative sum of auto-correlations of the input sequence at all possible lags:
act = 1 + 2 * sum(getACT(seq)) .
This option is merely provided for exploratory and education reasons.
-
the constant cumSumMax or an object of type cumSumMax_type(smin, smax, step), implying that the returned ACT is computed as the maximum of the cumulative sum of auto-correlations of the input sequence at all possible lags.
This option is merely provided for exploratory and education reasons.
This option is merely provided for exploratory and education reasons.
(optional, default = batchMeans_type(size = size(seq)**0.66).) |
- Returns
act
: The output scalar of the same type and kind as that of the input sequence, containing the estimated integrated autocorrelation time of the input sequence.
Possible calling interfaces ⛓
act
= getACT(seq(:), method
= method)
act
= getACT(seq(:), weight, method
= method)
Generate and return the integrated auto-correlation time (ACT) of the discrete signal.
This module contains classes and procedures for computing properties related to the auto correlation ...
- Warning
- The condition
1 < methodsmin
must hold for the corresponding input arguments.
The condition 0 < methodsignif
must hold for the corresponding input arguments.
The condition size(weight) == size(seq)
must hold for the corresponding input arguments.
The condition methodsmin <= methodsmax <= size(seq, 1) / 2
must hold for the corresponding input arguments.
The condition methodsize * 2 < sum(weight)
must hold for the corresponding input arguments, otherwise sum(weight)
will be returned as the act
.
The condition 1 < size(seq)
must hold for the corresponding input arguments, otherwise act
will be set to lenseq
on return.
The condition 0 < methodstep
must hold for the corresponding input arguments.
The condition 0 < methodsize
must hold for the corresponding input arguments.
- See also
- getACT
getACF
setACF
getCor
setCor
getRho
setRho
getCov
setCov
setECDF
getMean
setMean
getShifted
setShifted
getVar
setVar
Example usage ⛓
15 type(display_type) :: disp
16 character(:),
allocatable :: format
20 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
21 call disp%show(
"!Compute the cross-correlation of two samples.")
22 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
27 real(TKG),
allocatable :: table(:,:)
30 call disp%show(
"if (0 /= getErrTableRead(SK_'duluth.txt', table, sep = TAB, roff = 1_IK)) error stop 'table read failed.'")
31 if (
0 /= getErrTableRead(SK_
'duluth.txt', table, sep
= TAB, roff
= 1_IK))
error stop 'table read failed.'
32 call disp%show(
"act = getACT(table(:,2)) ! temperature see visualization below.")
36 call disp%show(
"act = getACT(table(:,2), method = batchMeans)")
40 call disp%show(
"act = getACT(table(:,2), method = batchMeans_type(size = 365_IK))")
44 call disp%show(
"act = getACT(table(:,2), method = batchMeansMax_type())")
49 call disp%show(
"act = getACT(table(:,2), method = batchMeansMax_type(step = 10_IK))")
53 call disp%show(
"act = getACT(table(:,2), method = cumSum)")
57 call disp%show(
"act = getACT(table(:,2), method = cumSum_type(signif = 5_IK))")
61 call disp%show(
"act = getACT(table(:,2), method = cumSum_type(signif = 0_IK))")
65 call disp%show(
"act = getACT(table(:,2), method = cumSumMax)")
77 character(:, SK),
allocatable :: header
78 integer(IK),
allocatable :: sbatch(:)
79 real(TKG),
allocatable :: output(:,:)
80 real(TKG),
allocatable :: table(:,:)
82 if (
0 /= getErrTableRead(SK_
'duluth.txt', table, header, sep
= TAB))
error stop 'table read failed.'
83 sbatch
= getRange(
2_IK,
size(table,
1,
IK)
/ 2_IK)
85 do ibatch
= 1,
size(sbatch,
1,
IK)
86 output(ibatch,
1)
= sbatch(ibatch)
89 if (
0 /= getErrTableWrite(SK_
'getACT.duluth.batchMeans.txt', output, header
= SK_
"batchSize"//TAB//SK_
"ACT", sep
= TAB))
error stop 'table read failed.'
91 table
= table(
1 :
size(table,
1,
IK) :
skip, :)
92 if (
0 /= getErrTableWrite(SK_
'getACT.duluth.thinned.txt', table, header
//SK_
" (BMM-thinned)", sep
= TAB))
error stop 'table read failed.'
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 the iostat code resulting from reading the contents of the specified file or unit...
Generate and return the iostat code resulting from writing the input table of rank 1 or 2 to the spec...
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
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 classes and procedures for input/output (IO) or generic display operations on st...
character(1, SK), parameter TAB
The scalar character of default kind SK of len = 4 representing representing ASCII character: Horizon...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
type(batchMeansMax_type), parameter batchMeansMax
type(batchMeans_type), parameter batchMeans
type(cumSumMax_type), parameter cumSumMax
type(cumSum_type), parameter cumSum
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
7if (
0 /= getErrTableRead(SK_
'duluth.txt', table, sep
= TAB, roff
= 1_IK))
error stop 'table read failed.'
Postprocessing of the example output ⛓
3import matplotlib.pyplot
as plt
13parent = os.path.basename(os.path.dirname(__file__))
14pattern = parent +
"*.txt"
15files = glob.glob(pattern)
19 df = pd.read_csv(file, delimiter =
"\t")
22 fig = plt.figure(figsize = (8, 6))
23 ax = plt.subplot(1,1,1)
24 ax.plot ( df.values[:, 0]
34 ax.set_xlabel(df.columns.values[0], fontsize = 17)
35 ax.set_ylabel(df.columns.values[1], fontsize = 17)
36 ax.tick_params(axis =
"x", which =
"minor")
37 ax.tick_params(axis =
"y", which =
"minor")
38 plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
39 ax.legend([
"Duluth, MN"], fontsize = fontsize)
41 plt.savefig(file.replace(
".txt",
".png"))
Visualization of the example output ⛓
- Test:
- test_pm_sampleACT
- Internal naming convention:
- The following illustrates the internal naming convention used for the procedures within this generic interface.
getACT_CSD_WTI_D1_CK5()
||| ||| ||| || |||
||| ||| ||| || The type and kind parameters of the input sequence.
||| ||| ||| The dimension of the input sequence `seq`.
||| ||| Weight type: WTTI => integer weight, ONE => no weight.
||| The method: BMD => BatchMeans Default, BMM => BatchMeans Maximum, CSD => CumSum Default, CSM => CumSum Maximum
ACF: Cross-Correlation Function.
- Todo:
- High Priority: The performance of the implementations of this generic interface can be improved by minimizing allocations and converting function calls to subroutine calls.
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.
-
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.
-
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.
- Copyright
- Computational Data Science Lab
- Author:
- Fatemeh Bagheri, Monday 02:15 AM, September 27, 2021, Dallas, TX
Definition at line 220 of file pm_sampleACT.F90.