How to choose from random patterns of varying lengths?

I want eight subdivisions per cycle, and for each subdivision randomly choose between “1 ~ 1” and “2”, while preserving the integrity of each pattern. For example:

| 1 ~ 1 2 2 2 1 ~ | 1 1 ~ 1 2 2 2 1 | ~ 1 2 2 1 ~ 1 2 |

I’ve tried markovPat, randcat, (<~), but none have worked.

This post has been moved here: How to randomly choose from patterns of varying lengths?