Implemented most of CuSum algorithm, still need to add square root function.