There is no rule like the one above governing their distribution. The sounds could be in complementary distribution . In this case, any environment that allows one of the sounds, doesn't allow the other. In the rules we've seen so far, one sound comes to be similar to an adjacent sound. These are rules of assimilation .
Languages have other kinds of rules such as deletion and insertion .
Rules of assimilation come in different varieties, depending on what aspects of the sounds are being assimilated. Above we saw assimilation rules in which a vowel assimilated to a nasal consonant by becoming nasal. One also finds rules of nasal assimilation applying between consonants. In each case, nasalization changes, but the rest stays the same. So often if a stop is adjacent to a vowel or vowels it will spirantize becoming a fricative.