def movvar(x, windowsize=3, lag='lagged'):
 m1 = movmoment(x, 1, windowsize=windowsize, lag=lag)
 m2 = movmoment(x, 2, windowsize=windowsize, lag=lag)
 return (m2 - (m1 * m1))

def movvar ( x , windowsize = 3 , lag = 'lagged' ) : m1 = movmoment ( x , 1 , windowsize = windowsize , lag = lag ) m2 = movmoment ( x , 2 , windowsize = windowsize , lag = lag ) return ( m2 - ( m1 * m1 ) )
moving window variance parameters x : array time series data windsize : int window size lag : lagged .