globalvar function

Computes global variance