Mathematical treatment of sequence distribution in terpolymers