Skip to content

avg function can now perform reblocking#11

Open
kkleiner1 wants to merge 1 commit intoWagnerGroup:mainfrom
kkleiner1:reblocked_avg_err
Open

avg function can now perform reblocking#11
kkleiner1 wants to merge 1 commit intoWagnerGroup:mainfrom
kkleiner1:reblocked_avg_err

Conversation

@kkleiner1
Copy link
Contributor

avg function in gather.py now computes averages and standard errors on correlated (via pyqmc's reblock function) or uncorrelated QMC data. See if this version is set up the way you like.

@lkwagner
Copy link
Contributor

I don't think you need the boolean argument. reblock is enough.

Also, actually I just noticed that this is incorrect for DMC; the weights need to be included, similar to this:

def weighted_reblock(array, weight, nblocks):
    """
    Helper function to reblock(); this function actually does the reblocking.
    """
    vals = np.array_split(array, nblocks, axis=0)
    weights = np.array_split(weight, nblocks, axis=0)

    return [ (v*w).mean(axis=0)/w.mean(axis=0) for v,w in zip(vals, weights)]

def read_mc_output(fname, warmup=5, reblock=16):
    ret = {"fname": fname, "warmup": warmup, "reblock": reblock}
    with h5py.File(fname,'r') as f:
        if 'weight' in f.keys():
            wt = f['weight'][warmup:]
        else:
            wt = 1.0
        for k in f.keys():
            if "energy" in k:
                vals = weighted_reblock(f[k][warmup:], wt, reblock)
                ret[k] = np.mean(vals)
                valserr = scipy.stats.sem(vals)
                ret[k + "_err"] = valserr
    return ret

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants