vp.liquids.error_calc
How correlation between successive values changes the error of a time average, shown on a series whose correlation time is known exactly. The series is a generalized Langevin process (an Ornstein-Uhlenbeck process in a memory variable), integrated with a random force; its statistical inefficiency is exactly s = 2 / (m delta) steps.
Part of the distribution vipyr-liquids; it runs from a checkout of the
repository. Planned on PyPI as pip install vipyr-liquids.
Signature
vp.liquids.error_calc(*, nstep=65536, nequil=10000, n_repeat=50, delta=0.01, variance=1.0, average=1.0, seed=1, series=zeros(0)) Parameters
- nstep : int, default
65536 - The length of each run of the process. Range: >= 64, <= 100000000.
- nequil : int, default
10000 - The steps run and discarded before each run. Range: >= 0, <= 100000000.
- n_repeat : int, default
50 - The independent runs of the brute-force error. Range: >= 2, <= 100000.
- delta : float, default
0.01 - The time step of the process. Range: > 0.
- variance : float, default
1.0 - The variance of the process's values. Range: > 0.
- average : float, default
1.0 - The mean of the process's values.
- seed : int, default
1 - The seed of the random numbers. Range: >= 0, <= 2147483646.
- series : ndarray[float64], default
zeros(0) - A series to analyze instead of the process (empty: run the process). Range: rank 1.
Returns
A frozen ErrorCalcResult. Iterating it gives the fields below in order; it also has
params, tests, log and check().
- si_exact : float
- The exact statistical inefficiency of the process, 2 tau, in steps.
- err_exact : float
- The exact error of a run's mean, sqrt(s var / nstep).
- err_brute : float
- The error from the scatter of the n_repeat runs' means (0 with series).
- mean : float
- The mean of the (last) series.
- var : float
- Its sample variance.
- err_naive : float
- The error of the mean ignoring correlation, sqrt(var / length).
- tblock_fixed : ndarray[float64]
- The block lengths of 20, 19, ..., 4 blocks.
- err_fixed : ndarray[float64]
- The error from the scatter of those blocks' means.
- si_fixed : ndarray[float64]
- The statistical inefficiency each gives.
- tblock_halving : ndarray[float64]
- The block lengths 2, 4, 8, ... of repeated halving.
- err_halving : ndarray[float64]
- The error after each halving.
- si_halving : ndarray[float64]
- The statistical inefficiency each gives.
Raises
- vipyr.ParameterError
- A ValueError: an argument outside its range, choices, rank or shape, or one of a group given without the rest; its .param names the argument.
- TypeError
- An argument of the wrong type, or an unknown keyword.
- vipyr.VivBuildError
- An ImportError: no C compiler, or the program's C does not build.
- RuntimeError
- The program stops with its own message (a combination it rejects, or no convergence where the program treats that as an error).
Examples
import vipyr as vp
r = vp.liquids.error_calc(nstep=4096, nequil=1000, n_repeat=4)
print(r.si_exact, r.si_halving) # s levels off toward 2 tau = 800 steps
assert r.check() 800.0 [ 2.00044299 4.00248181 8.01000933 16.03039293 32.04372645
63.61627253 126.45417783 237.56904618 436.36393229 849.76126227]Each example ran as written when these pages were generated, and the output shown is what it printed.
Checked against
- Tests
- ports/liquids/test_liquids.py: every tolerance is stated beside its check
- Upstream
- error_calc of https://github.com/Allen-Tildesley/examples at 4818bc82, built with gfortran -O2 by ports/liquids/oracle/build.py; same bits from the same start and random numbers
Credits
- A port of the examples of Allen and Tildesley's Computer Simulation of Liquids, which are CC0-1.0.
Source
- Manifest: ports/liquids/error_calc.export.toml
- Viv: ports/liquids/error_calc.viv
- The defs it reaches and the calls between them: map of the code