
Bayesian Reweighting with Gibbs Sampler (BRwGS)
    Based on M. Habeck, "Bayesian Estimation of Free Energies From Equilibrium Simulations", Phys. Rev. Lett. 109:100601 (2012)
    and C. Bartels, "Analyzing Biased Monte Carlo and Molecular Dynamics Simulations", Chem. Phys. Lett. 331:446 (2000)
    Coded by Mahmoud Moradi, UIUC (last modified on 11/07/2013)
    It first uses the C. Bartles deterministic method then it draws multiple distributions using Gibbs sampler
    Usage:  stdin: data
            stdout: optimized probabilities
            stderr: log file including the free energy of images
            arguments:
            --windows (-w) number of windows (default: 1)
            --lines (-l) number of data points (lines) read from the stdandard input  (default: 1)
                        Each line (in stdin) includes "i t u_0 u_1 ... "
                                  t and i are the time and window index (both integers)
                                  u_i is the biasing potential associated with the window i
            --iterations (-i) maximum number of iterations for self-consistent solution (default: 1000)
            --gibbs (-g) number of Gibbs sampling repeats (default: 1; i.e., no Gibbs sampling)
            --accuracy (-a) accuracy in kcal/mol for self-consistent solution of C. Bartels method (default: 0.1)
            --temperature (-t) simulation temperature in Kelvin (default: 300)
            --restart (-r) a filename to store resulted p's and f's to continue iterations (default: "")
            --start (s) an existing restart file to continue iterations (default: "")
    Program generates the {p(i,t)} probability for each data point "I i t p" (in stdout)
    I is the Gibbs sampler repeat; I=0 repeat: the solution based on C. Bartels method
    Program also reports the estimated free energies of windows (at the end of each iteration) in stderr

EXAMPLE:

l=`wc data.txt | awk '{print $1}'` # number of data points (you can use only a portion of the data)
# No Gibbs Sampling Used:
./brwgs -w $N -l $l -t 310 -g 0 < data.txt > density.txt 2> density.err
# Gibs Sampling Used (100 repeats):
./brwgs -w $N -l $l -g 100 -t 310 < data.txt > density.txt 2> density.err
