update function for 2nd moment and script for test error bound