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$?
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.