1. A method for minimizing the number of appearances of a given state in a code word generated from a data word comprising: counting the number of times the given state appears in the data word; if the count is greater than half of a total number of bits in the data word, then inverting the data word; setting a weight bit to the given state; and else setting the weight bit to an inverse of the given state.