1 Unconstrained and Pinned Solus Bitstrings
Given a random unconstrained bitstring of length , we have
because a sum of independent Bernoulli() variables is Binomial(,). Expressed differently, the average density of s in a string is , with a corresponding variance . The word “unconstrained” offers that, in the sampling process, all strings are included and equally weighted.
If we append the string with a , calling this , then there is a natural way [7] to associate with an additive composition of . For example, if ,
i.e., parts of correspond to “waiting times” for each in . The number of parts in is equal to the number of s in and the maximum part in is equal to the duration of the longest run of s in , plus one.
In this paper, the word “constrained” refers to the logical conjunction of two requirements:
-
A bitstring is pinned if its first bit is and its last bit is .
-
A bitstring is solus if all of its s are isolated.
The latter was discussed in [2, 3]; additionally imposing the former is new. Given a random pinned solus bitstring of length , formulas for number of s and number of s are best expressed using generating functions.
If we append the string with to construct , then the associated is a composition of with all parts . For example, if ,
It should now be clear why, starting with the original -bitstring,
for both scenarios, but the corresponding variances are always equal.
Nej & Satyanarayana Reddy [8] gave an impressive recursion for the number of unconstrained bitstrings of length containing exactly s and a longest run of exactly s:
where (of course) and ,
and
Consequently, the numerator of for -bitstrings is
equivalently, the numerator of for -compositions is
The denominator is . Returning to the unrestricted example, the covariance for is . Correlations for selected small turn out to be
and Table 1 exhibits values for larger .
By a similar argument, we deduce the number of pinned solus bitstrings of length containing exactly s and a longest run of exactly s. The recursion is identical to before (with replaced by ) but possesses different initial conditions
where , with a different :
and a different :
Consequently, the numerator of under constraints is
equivalently, the numerator of under restrictions is
The denominator is . Returning to the -free example, the covariance for is . Correlations for selected small turn out to be
i.e., dependency is more significant than earlier. Table 1 exhibits values for larger .
2 Sketches of Proofs
Let be a set of finite bitstrings and be the subset of consisting of strings of length containing exactly s and a longest run of exactly s. Let and be the subset of of strings starting with and respectively.
Assume that consists of all unconstrained strings. If , then is of the form where . If , then is of the form
or
We have
(1) |
hence
upon addition. This proof of the recurrence for appeared in [8].
Assume instead that consists of all solus strings. If , then is of the form where . We have
that is,
From formula (1) in the preceding,
which gives a recurrence underlying what we called in [3].
Let us turn attention to various boundary conditions. For either unconstrained or solus strings,
if is odd, then
if is even, then
These imply the expression for . For pinned strings, the latter two results hold, but the former becomes . The expression for comes from [8]
For completeness’ sake, we give the analog of Table 1 for pinned and solus strings.
Table 2: Correlation between number of s and longest run of s within random bitstrings as a function of .
3 Acknowledgements
R, Mathematica and Maple have been useful throughout. I am grateful to Ernst Joachim Weniger, Claude Brezinski and Jan Mangaldan for very helpful discussions about convergence acceleration. Dr. Weniger’s software code and numerical computations were especially appreciated.
References
- [1] R. Sedgewick and P. Flajolet, Introduction to the Analysis of Algorithms, Addison-Wesley, 1996, pp. 120–121, 159–161, 366–373, 379.
- [2] S. R. Finch, Cantor-solus and Cantor-multus distributions, arXiv:2003.09458.
- [3] S. R. Finch, Variance of longest run duration in a random bitstring, arXiv:2005.12185.
- [4] D. W. Boyd, Losing runs in Bernoulli trials, unpublished note (1975), https://www.math.ubc.ca/~boyd/bern.runs/bernoulli.html.
- [5] M. F. Schilling, The longest run of heads, College Math. J. 21 (1990) 196–207; MR1070635.
- [6] A. Alexandru, The longest run of heads, unpublished note (2011), https://alexamarioarei.github.io/Research/Research-en.html.
- [7] P. Hitczenko and C. D. Savage, On the multiplicity of parts in a random composition of a large integer, SIAM J. Discrete Math. 18 (2004) 418–435; MR2112515.
-
[8]
M. Nej and A. Satyanarayana Reddy, Binary strings of length
with zeros and longest -runs of zeros, Indian J. Math. 61
(2019) 111–139; arXiv:1707.02187; MR3931610.
Steven Finch MIT Sloan School of Management Cambridge, MA, USA steven_finch@harvard.edu