Suppose I have a binary vector of sample size N with each of the two possible values (e.g., 0 and 1 occurring equally often).For example, if N=10, the binary vector is: 0 0 0 0 0 1 1 1 1 1Suppose I have another parameter called 'limit' which indicates the maximum amount of times that the same number can occur consecutively in the randomized vector when read from left to right.For example, if limit=3, two 0s or two 1s after each other are ok and three 0s or three 1s are ok but no more.Some randomizations of the vector above according to these constraints (limit = 3) would be:1 0 1 0 1 0 1 0 1 0  or 1 1 1 0 0 0 1 1 0 0 or 0 1 0 1 1 1 0 0 1 0Does anyone know how to program a simple algorithm that randomizes a binary vector according to the method above with 'N' and 'limit' as input parameters?
Restricted randomization of a binary vector
algorithms;random;binary;combinatorics