function to calculate entropy in string