Package: correlated-ts-ci
Correlated timeseries confidence intervalsPurposeEstimate confidence intervals in means of correlated time series with a small number of effective samples (like molecular dynamics simulations). If your time series is long enough that the standard error levels off completely as a function of block length, then this method is overkill and simply using a block bootstrap sampling with a sufficiently large block length is probably sufficient.BackgroundThe origin of this method is in the Appendix of [1]. It based on computing standard error as a function of block length, fitting this, then extrapolating to infinite block length. For correlated data, the standard error will increase asymptotically with increasing block length. Some improvements on the original method are implemented here. The first is to give the option to vary the prefactor for the fitted function which can sometimes give a significantly better fit. The second is to give the option to perform stationary block bootstrap sampling for each block size instead of just using a single set of blocks for each block size. This significantly reduces the noise in the data and leads to better fits.Installationpipinstallcorrelated_ts_ciUsageCommand linepython-mcorrelated_ts_ci[-h][-opOUTPREFIX][-idINDIR][-odOUTDIR][-tuTIME_UNIT][-eqEQTIME][-skSKIP][-vp][-slSIG_LEVEL][-mbMIN_BLOCKS][-bsnBLOCK_SIZE_NUMBER][-cfCUSTOM_FUNC][-nbNBOOTSTRAP][-npNPROCS]infilecolnumpositional arguments:infileFile with time in the first column and other quantities in subsequent columns.colnumColumn number in the file with the quantity to be analyzed. The first column (time) is numbered 0, so this should be >= 1.optional arguments:-h, --helpshow this help message and exit-op OUTPREFIX, --outprefix OUTPREFIXPrefix for output files. Default is the prefix of the input file.-id INDIR, --indir INDIRDirectory input file is located in. Default is current directory.-od OUTDIR, --outdir OUTDIRDirectory to write data to. Default is current directory.-tu TIME_UNIT, --time_unit TIME_UNITString to specify time units. 'ns', 'ps', etc. Default is 'ps'.-eq EQTIME, --eqtime EQTIMEEquilibration time in unit of input file. Default is 0.0.-sk SKIP, --skip SKIPOnly use every this many data points from the input file.-vp, --vary_prefacVary the prefactor instead of constraining it to a constant value of 2 times the standard deviation of all data divided by the total time covered by the data. This is a flag.-sl SIG_LEVEL, --sig_level SIG_LEVELSignificance level for computing confidence intervals. Default is 0.05.-mb MIN_BLOCKS, --min_blocks MIN_BLOCKSMinimum number of blocks. Default is 30.-bsn BLOCK_SIZE_NUMBER, --block_size_number BLOCK_SIZE_NUMBERNumber of block sizes to consider. Default is 100.-cf CUSTOM_FUNC, --custom_func CUSTOM_FUNCCustom lambda function taking a single argument. This function contains the definition of the quantities which you wish to obtain the uncertainties for and should return a single value or a numpy row vector. Example -- lambda x: np.hstack((np.mean(x), np.percentile(x, 90))). If not specified, only np.mean is used.-nb NBOOTSTRAP, --nbootstrap NBOOTSTRAPNumber of bootstrap samples. Default is 100.-np NPROCS, --nprocs NPROCSNumber of processors to use for calculation. Default is all available.ExampleAnalyze column 1 of the specified file. Use nanoseconds (ns) for the time unit with an equilibration time of 0.5 ns. All other options default.python-mcorrelated_ts_ci./velocities/ads_lower_all_velocity.xvg1-tuns-eq0.5Scriptfromcorrelated_ts_ciimportConfidenceIntervalget_confidence_interval=ConfidenceInterval(infile,colnum)get_confidence_interval(outfile_prefix=OUTPREFIX,eqtime=EQTIME,skip=SKIP,indir=INDIR,time_unit=TIME_UNIT,vary_prefactor=VARY_PREFAC,sig_level=SIG_LEVEL,block_size_number=BLOCK_SIZE_NUMBER,min_blocks=MIN_BLOCKS,custom_func=CUSTOM_FUNC,nbootstrap=NBOOTSTRAP,nprocs=NPROCS,outdir=OUTDIR)References(1) Hess, B. Determining the Shear Viscosity of Model Liquids from Molecular Dynamics Simulations. J. Chem. Phys. 2002, 116, 209–217.https://doi.org/10.1063/1.1421362.