I have a random binary string of N bits with N/2 bits are one and N/2 bits are zero and the bits are generated by coin tossing so they have entropy N. Now I feed the bits to a deterministic algorithm that generates psuedorandom permutations of these N bits with the restriction that for each permutation you are not allowed three consecutive bits with the same value ( you can have 1001 but not 10001 anywhere in the sequence). How many ways can N be arranged? And finally does each string generated have the same entropy as the original string?
-
The word permutation is awkward for arrangements with repetitions (of indistinguishable items). Here you speak of "bits", so presumably only zeros and ones are involved. I'd be inclined to speak instead of binary sequences of length $N$. – hardmath Sep 03 '17 at 21:06
-
For the "how many ways" part, is this your question? How many binary sequences of length $2m$ have an equal number of ones and zeros, and no $3$ consecutive terms are equal? Is that what you want to find? – quasi Sep 03 '17 at 21:38
-
@quasi: Yes, where does 2m come from in your comment? The string is length N . – William Hird Sep 03 '17 at 21:56
-
But $N$ must be even, so $m=N/2$. – quasi Sep 03 '17 at 22:00
-
@quasi: OK, I got it. – William Hird Sep 03 '17 at 22:02
-
Related paper and sequence. – jblood94 Mar 14 '24 at 11:36
2 Answers
If you know that exactly $\frac N2$ bits are $1$ and $\frac N2$ bits are $0$ the string does not have entropy $N$. There are ${N \choose N/2}=\frac {N!}{((N/2)!)^2}\approx \frac {2^N}{\sqrt {\frac \pi 2 N}}$ such strings, so the entropy is about $N-\frac 12\log_2 N-\frac 12 (\log_2 \pi -1)$, not much of a reduction. Restricting to strings which do not have three in a row decreases the number of allowable strings, so the entropy is decreased. I don't see an easy way to impose both requirements (same number of $1$s and $0$s and no three in a row) simultaneously. The number of strings lacking three in a row satisfies the Fibonacci recurrence because an acceptable string of length $N$ can be an acceptable string of length $N-1$ to which you append the opposite bit to the last or an acceptable string of length $N-2$ to which you append two opposite bits. That costs you a factor $\log_2 1.618 \approx 0.694$ on your entropy.
- 374,822
-
Why doesn't the original string have entropy N, why does the fact that you know the string happens to be balanced that it reduces the entropy? – William Hird Sep 03 '17 at 22:00
-
1Because having it balanced reduces the number of strings. To have entropy $N$ you must be choosing between $2^N$ things, but there are not that many. It is a small reduction, just the factor in the denominator, but there are less of them. For example, if $N=4$ there are only $6$ balanced strings out of $16$ total strings, so the entropy is only $\log_2 6 \approx 2.58$ bits. – Ross Millikan Sep 04 '17 at 04:52
- 58,772
-
I'm looking for a answer that is a function of N. How did you come up with an integer, I never gave you a value for N. – William Hird Sep 03 '17 at 22:16
-
A closed form is unlikely. A recursion allows calculation for a given value of $N$. The output is just a demo of the recursion for even values of $N$ with $2 \le N \le 20$, and also, just for show, for $N=100$. – quasi Sep 03 '17 at 22:21
-
OK, so this big number (looks like the national debt !) is for N=100, is this with the restriction of no three consecutive bits can be the same? – William Hird Sep 03 '17 at 22:36
-
Yes. For an even positive integer $n$, $f(n)$ is the number of binary sequences of length $n$ with equally many ones and zeros, and such that no $3$ consecutive terms are equal. I can do $f(1000)$ just as easily -- takes about 1 sec, but it's really big. – quasi Sep 03 '17 at 22:46
-
-
-
Just for giggles, what would N of 256 be, I might need to establish an upper bound later for my hash function. Thanks again ! – William Hird Sep 03 '17 at 23:48
-
