evaluate and return variance of accumulators in accumulator.avg() methods, and accumulate the variance in vmc and dmc.
- in each accumulator object, the avg() method currently computes the mean over all configs of the values for each key k. in addition, compute the variance and store in the key
f"{k}_var"
- In vmc, where steps are accumulated in each block, initialize block mean and variance to zero. First increment the variance as
var = i/(i+1) *(var + (v - avg)**2 / (i+1)), then increment the mean as avg += 1/(i+1) (v - avg) where i is the step number.
- In dmc, averages are not accumulated at each step, but we will implement that. Initialize block mean, block variance, and block weight to zero. At step
i, increment the weight average as wavg += (w - wavg)/i (w is the current weight). Define S = wavg*i. Then increment the variance as var = (1 - w/S) *(var + (v - avg)**2 * w/S), then increment the mean as avg += (v - avg) * w/S where i is the step number.
- Write tests that verify the variance is evaluated correctly (final variance roughly matches the variance estimated from the mean values of each block)
At the end of a VMC or DMC calculation, the variance can be evaluated as var(X) = mean(X_var) + var(X_mean) over the values saved for each block.
evaluate and return variance of accumulators in accumulator.avg() methods, and accumulate the variance in vmc and dmc.
f"{k}_var"var = i/(i+1) *(var + (v - avg)**2 / (i+1)), then increment the mean asavg += 1/(i+1) (v - avg)where i is the step number.i, increment the weight average aswavg += (w - wavg)/i(w is the current weight). DefineS = wavg*i. Then increment the variance asvar = (1 - w/S) *(var + (v - avg)**2 * w/S), then increment the mean asavg += (v - avg) * w/Swhere i is the step number.At the end of a VMC or DMC calculation, the variance can be evaluated as
var(X) = mean(X_var) + var(X_mean)over the values saved for each block.