| 1 |
.. currentmodule:: pymbar.timeseries |
| 2 |
|
| 3 |
The timeseries module :mod:`pymbar.timeseries` |
| 4 |
============================================== |
| 5 |
|
| 6 |
The :mod:`pymbar.timeseries` module contains tools for dealing with timeseries data. |
| 7 |
The `MBAR <http://www.alchemistry.org/wiki/Multistate_Bennett_Acceptance_Ratio>`_ method is only applicable to |
| 8 |
uncorrelated samples from probability distributions, so we provide a number of tools that can be used to decorrelate |
| 9 |
simulation data. |
| 10 |
|
| 11 |
Automatically identifying the equilibrated production region |
| 12 |
------------------------------------------------------------ |
| 13 |
|
| 14 |
Most simulations start from initial conditions that are highly unrepresentative of equilibrated samples that occur |
| 15 |
late in the simulation. |
| 16 |
We can improve our estimates by discarding these initial regions to "equilibration" (also known as "burn-in"). |
| 17 |
We recommend a simple scheme described in Ref. :cite:`chodera:jctc:2016:automatic-equilibration-detection`, which |
| 18 |
identifies the production region as the final contiguous region containing the *largest* number of uncorrelated samples. |
| 19 |
This scheme is implemented in the :func:`detect_equilibration` method: |
| 20 |
|
| 21 |
.. code-block:: python |
| 22 |
|
| 23 |
from pymbar import timeseries |
| 24 |
t0, g, Neff_max = timeseries.detect_equilibration(A_t) # compute indices of uncorrelated timeseries |
| 25 |
A_t_equil = A_t[t0:] |
| 26 |
indices = timeseries.subsample_correlated_data(A_t_equil, g=g) |
| 27 |
A_n = A_t_equil[indices] |
| 28 |
|
| 29 |
In this example, the :func:`detect_equilibration` method is used on the correlated timeseries ``A_t`` to identify the |
| 30 |
sample index corresponding to the beginning of the production region, ``t_0``, the statistical inefficiency of the |
| 31 |
production region ``[t0:]``, ``g``, and the effective number of uncorrelated samples in the production |
| 32 |
region, ``Neff_max``. |
| 33 |
The production (equilibrated) region of the timeseries is extracted as ``A_t_equil`` and then subsampled using |
| 34 |
the :func:`subsample_correlated_data` method with the provided statistical inefficiency ``g``. |
| 35 |
Finally, the decorrelated samples are stored in ``A_n``. |
| 36 |
|
| 37 |
Note that, by default, the statistical inefficiency is computed for every time origin in a call to |
| 38 |
:func:`detect_equilibration`, which can be slow. |
| 39 |
If your dataset is more than a few hundred samples, you may want to evaluate only every ``nskip`` samples as potential |
| 40 |
time origins. |
| 41 |
This may result in discarding slightly more data than strictly necessary, but may not have a significant impact if the |
| 42 |
timeseries is long. |
| 43 |
|
| 44 |
.. code-block:: python |
| 45 |
|
| 46 |
nskip = 10 # only try every 10 samples for time origins |
| 47 |
t0, g, Neff_max = timeseries.detect_equilibration(A_t, nskip=nskip) |
| 48 |
|
| 49 |
Subsampling timeseries data |
| 50 |
--------------------------- |
| 51 |
|
| 52 |
If there is no need to discard the initial transient to equilibration, the :func:`subsample_correlated_data` method can be |
| 53 |
used directly to identify an effectively uncorrelated subset of data. |
| 54 |
|
| 55 |
.. code-block:: python |
| 56 |
|
| 57 |
from pymbar import timeseries |
| 58 |
indices = timeseries.subsample_correlated_data(A_t_equil) |
| 59 |
A_n = A_t_equil[indices] |
| 60 |
|
| 61 |
Here, the statistical inefficiency ``g`` is computed automatically. |
| 62 |
|
| 63 |
Other utility timeseries functions |
| 64 |
---------------------------------- |
| 65 |
|
| 66 |
A number of other useful functions for computing autocorrelation functions from one or more timeseries sampled from the |
| 67 |
same process are also provided. |
| 68 |
|
| 69 |
.. automodule:: pymbar.timeseries |
| 70 |
:members: |