# Re: Error Analysis in Metadynamics

From: Giacomo Fiorin (giacomo.fiorin_at_gmail.com)
Date: Fri Apr 23 2021 - 10:57:34 CDT

Hi Diship, it highly depends on what error analysis you plan on doing. The
approach that I and others use with metadynamics has very few assumptions:
after estimating that the systems has explored all relevant states at least
once, start collecting the PMF at regular intervals and simulate for
additional time such that all states are visited a few more times, i.e. a
few more layers of Gaussian hills are added on top of the converged PMF.
Then just compute the average and SD of the free-energy over the sample of
multiple PMFs, which are only text files, so you can do the following:

all_pmfs = np.zeros(shape=(n_files, n_points))
for i_file in range(n_files):
all_pmfs[i_file,:] = pmf[:]
pmf_mean = all_pmfs.mean(axis=0)
pmf_SD = all_pmfs.std(axis=0)

The tutorial that Miro has linked uses block averages, where the additional
difference is that the length of the blocks is also varied to converge the
SD. You should see for yourself that the dependence of the SD on the block
length is rather slow (in theory, it should follow a square root).

Having said all that, here you're not simulating something trivial like
dialanine isomerization: any meaningful error estimate will require that
the CV has already visited all states repeatedly during the simulation. If
you can see such trajectory, then you're in good shape and any PMF method
including metadynamics will give you unbiased results. If you ran long
enough for today's review standards, your statistical error bars will be
comparable or smaller than the size of the marker used in the plot :-) You
ought to be able to explain how you computed the statistical error bars,
but these ought to be very small or downright negligible.

On the other hand, if the CV is not a good reaction coordinate any error
analysis will be uninformative: you need to analyze the atomic trajectory
and show that at any given frame the structural properties (e.g.
coordination with water or lipids) depend only on the value of the CV, but
not on the simulation history. Any inconsistency that you may see there
may not easily be solved with longer simulation times.

In short, statistical sampling is less of an issue than it used to be (the
most common PMF methods are now at least two decades old!), but *picking a
good CV* has always been "the big deal", where your insight into the
specific problem matters the most.

Giacomo

On Tue, Apr 20, 2021 at 3:37 AM Miro Astore <miro.astore_at_gmail.com> wrote:

> Hi Diship, you should be able to use the code/techniques in this tutorial.
> Good luck.
>
> https://urldefense.com/v3/__https://www.plumed.org/doc-v2.5/user-doc/html/trieste-4.html__;!!DZ3fjg!oP-_Zk-rfJChIEjBoYdFZ4a-Y4DgRZdCY9AUJTqbm92S-vv-5rzsvY3QhKNr8w0SoQ\$
> <https://urldefense.com/v3/__https://www.plumed.org/doc-v2.5/user-doc/html/trieste-4.html__;!!DZ3fjg!sp8OPR83ZO7SNR9X9YYdw-9CIV1DXCkkqKUva3mWJ5o6ou3SWvonbwVzjmecWx3n9w\$>
>
> On Tue, Apr 20, 2021 at 4:41 PM Diship Srivastava <
> dishipsrivastava_at_gmail.com> wrote:
>
>> Hi,
>> I have done well tempered metadynamics for a system consisting of a
>> molecule insertion into a bilayer using the colvars module. I am
>> interested in doing an error analysis for obtained free energy
>> preferably using colvars.
>> Any help would be most appreciated.
>>
>>
>>
>>
>> --
>> Diship Srivastava
>> JRF
>> Department of Chemistry