Pattern: PFlipFlop
Flip a binary bit with some probability.
initialis initial value (0 or 1)p_onis chance of switching from 0->1p_offis chance of switching from 1->0
Example output
>>> p = PFlipFlop(0, 0.9, 0.5)
>>> p.nextn(16)
[1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1]