Added CHECK FOR ZERO SUM IN THRESHOLD PLOT

THIS IS SPOTLESS CODE, WITH ERROR CHECKS , PLEASE USE THIS FOR ALL
CALCULATIONS UNIFORMLY