discrepancy function

Calculates discrepancy of a matrix