Formula to generate sequence while enforcing a particular number within X items I need to generate a sequence of 0s and 1s. I want to ensure that there's always at least one 1 within a sequence of 8 numbers. What formula do I use to generate this sequence?
One option would be enforce a 1 on every 8th number and then use different probabilities for the remaining 7 items. However, I would prefer avoiding a sequence as predictable as this.

Generate your first seven entries by tossing a coin with the appropriate probability.
Starting with the eighth entry, always look back to the seven previous entries before generating a new one. If there are no 1s in the last seven entries, the new one must be a 1. If there is a 1, again simply determine the new entry by tossing your coin.
Overall, you will get slightly more 1s than just tossing each coin independently with the input probability would yield, but that is expected.
