2

Let's say there is a set $\mathcal{S}$ of 32-bit random integers, where each bit is denoted from $b_0$ to $b_{31}$.

I want to know how to compute the cardinality $c =$ #$\mathcal{S}$ from which $\mathcal{S}$ could contains $n$ integers having $x$ successive constant bits, with a high probability $p$.

For example, how big should $c$ be to have $n = 200$ integers with $b_0$ to $b_{11}$ constant (i.e. $x=12$) with a probability $p \geq 0.9$?

Raoul722
  • 215
  • 2
  • 15
  • Trivial rewrite: replace your numbers by bit-strings, i.e. elements of $(\mathbb Z/2)^{12}$; and instead of drawing the numbers $x_n$ themselves (I assume, independently uniform), draw the differences $x_{n+1} - x_n$ (also independently uniform). Then you are looking at the probability that $200$ consecutive draws are zero, when the probability that each draw is zero is $2^{-12}$. To solve this problem, look here: https://math.stackexchange.com/questions/364038/expected-number-of-coin-tosses-to-get-five-consecutive-heads – Circonflexe Apr 25 '17 at 15:05
  • @Circonflexe In fact I don't want that 200 consecutive draws are zero, I want that 200 draws are zero (only the constant bits must be consecutive (i.e. $b_0$ to $b_{11}$)) – Raoul722 Apr 26 '17 at 08:13

1 Answers1

2

There are $2^{12}=4096$ possibilities for the $12$ bits. You can guarantee that there will be $200$ numbers that match all $12$ of these bits if $c=199\cdot 4096+1$ by the pigeonhole principle.

For an approximate answer to the question of how many you need for a lower probability we will use the Poisson distribution. For a given set of the $12$ bits, the chance that each number matches those is $\frac 1{2^{12}}$ so the expected number is $\lambda=\frac c{2^{12}}$. The chance of having at least $200$ is $p_1=\sum_{k=200}^\infty \frac {\lambda^ke^{-\lambda}}{k!}$. The chance that none of them have at least $200$ is then $(1-p_1)^{4096}$ which you want less than $0.1$. We get $p_1 \approx 0.000562$ Solving for $\lambda$ can be done using the incomplete gamma function, but I can't get an answer out of Alpha. This pretends that the even of a number going in one set of $12$ bits is independent of its going in another set of $12$ bits, which is not absolutely correct but not far off because the number of sets is large.

Ross Millikan
  • 374,822