parfor for error calculation