Add variance distribution computation and fixes Nan bug