Efficient coding explains the universal law of generalization in human perception