Optimal Discrimination between Transient and Permanent Faults