DeepAI

# Variance of Longest Run Duration in a Random Bitstring

We continue an earlier study, starting with unconstrained n-bitstrings, focusing now less on average behavior and more on uncertainty. The interplay between ∙ longest runs of 0s and of 1s, when bitstrings are multus ∙ longest runs of 0s and bitsums (# of 1s), when bitstrings are solus is examined. While negative correlations approach zero as n →∞ in the former (for clumped 1s), the limit is evidently nonzero in the latter (for separated 1s). Similar analysis is possible when both 0s and 1s are clumped (bimultus), and when 0s are clumped but 1s are separated (persolus). Our methods are experimentally-based.

11/11/2021

### DropGNN: Random Dropouts Increase the Expressiveness of Graph Neural Networks

This paper studies Dropout Graph Neural Networks (DropGNNs), a new appro...
09/12/2022

### Introducing Grid WAR: Rethinking WAR for Starting Pitchers

Traditional methods of computing WAR (wins above replacement) for pitche...
01/30/2019

### Computing runs on a trie

A maximal repeat, or run, in a string, is a periodically maximal substri...
02/23/2018

### Optimized Algorithms to Sample Determinantal Point Processes

In this technical report, we discuss several sampling algorithms for Det...
03/31/2019

### CUSUM ARL - Conditional or Unconditional?

The behavior of CUSUM charts depends strongly on how they are initialize...
03/20/2019

### Is Basketball a Game of Runs?

Basketball is often referred to as "a game of runs." We investigate the ...
06/21/2022

### Robustness against data loss with Algebraic Statistics

The paper describes an algorithm that, given an initial design ℱ_n of si...

## 1 Constrained Cases

The first two examples of constrained bitstrings were introduced in [8].

• A bitstring is solus if all of its s are isolated.

• A bitstring is multus if each of its s possess at least one neighboring .

Counts of solus -bitstrings have a quadratic character:

 ∞∑n=0dnzn=1+z1−z−z2=1+2z+3z2+5z3+8z4+13z5+21z6+34z7+⋯,

whereas counts of multus -bitstrings have a cubic character:

 ∞∑n=0dnzn=1−z+z21−2z+z2−z3=1+z+2z2+4z3+7z4+12z5+21z6+37z7+⋯.

The remaining two examples are new, as far as is known.

• A bitstring is bimultus if each of its s possess at least one neighboring and each of its s possess at least one neighboring .  Both isolated bits and isolated bits are avoided in such bitstrings; a certain symmetry holds here.

• A bitstring is persolus if all of its s are isolated and each of its s possess at least one neighboring .  That is, while s in solus bitstrings are alone, s in persolus bitstrings are very alone.

Counts of bimultus -bitstrings have a quadratic character [9]

 ∞∑n=0dnzn=2z21−z−z2=2z2+2z3+4z4+6z5+10z6+16z7+⋯,

whereas counts of persolus -bitstrings have a cubic character

 ∞∑n=0dnzn=z(1+2z2)1−z−z3=z+z2+3z3+4z4+5z5+8z6+12z7+⋯.

## 2 Bitsums

Given a set of finite bitstrings, what can be said about the bitsum of a random of length ?  If is unconstrained, i.e., if all strings are included in the sample, then

 E(Sn)=n/2,V(Sn)=n/4

because a sum of independent Bernoulli() variables is Binomial(,).  Expressed differently, the average density of s in a random unconstrained string is , with a corresponding variance .

We previously covered solus and multus bitstrings in [8].  If consists of bimultus bitstrings, then the total bitsum of all of length has generating function [9]

 ∞∑n=0anzn=z2(2−z)(1−z−z2)2=2z2+3z3+8z4+15z5+30z6+⋯

and the total bitsum squared has generating function

 ∞∑n=0bnzn=z2(4−7z+4z2−z3+4z4−z5)(1−z+z2)(1−z−z2)3=4z2+9z3+24z4+51z5+114z6+⋯;

hence has generating function

 ∞∑n=0cnzn =z2(4−11z+11z2−13z3+2z4+17z5−5z6−z7)(1+z)2(1−3z+z2)2(1−z+2z2+z3+z4) =4z2+9z3+32z4+81z5+240z6+⋯.

Standard techniques [1] give asymptotics

 limn→∞E(Sn)n=limn→∞anndn=12,
 limn→∞V(Sn)n=limn→∞cnnd2n=5+3√540=0.2927050983...

for the average density of s in a random bimultus string and corresponding variance.

If instead consists of persolus bitstrings, then the total bitsum of all of length has generating function [9]

 ∞∑n=0anzn=z(1−z+z2)2(1−z−z3)2=z+2z3+4z4+5z5+10z6+⋯

and the total bitsum squared has generating function

 ∞∑n=0bnzn=z(1−z+z2)2(1−z+z3)(1−z−z3)3=z+2z3+6z4+7z5+16z6+⋯;

hence has generating function

 ∞∑n=0cnzn =z3(2+4z−6z2−6z3−16z4−8z5+8z6+14z7+5z8−2z9−3z10−z11)(1−z−2z2−z3)2(1+z2−z3)3 =2z3+8z4+10z5+28z6+⋯.

We obtain asymptotics

 limn→∞E(Sn)n =limn→∞anndn =13⎡⎢⎣1−(31+3√931922)1/3−(31−3√931922)1/3⎤⎥⎦ =0.1942540040...,
 limn→∞V(Sn)n =limn→∞cnnd2n =12883(932)1/3[(8649+457√93)1/3+(8649−457√93)1/3] =0.0495615175...

for the average density of s in a random persolus string and corresponding variance.  Unsurprisingly and , where

are estimates associated with solus strings and

are estimates associated with multus strings [8].  While insisting on symmetry forces equiprobability, it also increases the variance, but only slightly.

## 3 Longest Bitruns

Given a set of finite bitstrings, what can be said about the duration of the longest run of s in a random of length ?  We have already discussed the case when is unconstrained.  Preliminary coverage for constrained (for means, but not mean squares) occurred in [8].

If consists of solus bitstrings, then it makes little sense to talk about -runs.  For -runs, over all , we have

 Hk(z)=1+z−zk−zk+11−z−z2+zk+1,H(z)=1+z1−z−z2;

the Taylor expansion of the numerator series for is

 z+4z2+9z3+18z4+34z5+62z6+110z7+192z8+331z9+565z10+⋯

and the Taylor expansion of the numerator series for is

 z+6z2+19z3+48z4+106z5+218z6+424z7+798z8+1463z9+2631z10+⋯.

Let us abbreviate such series as and for simplicity – likewise and – and let denote the Golden mean.  It is conjectured that, up to small periodic fluctuations,

 E(Rn,0)∼ln(n)ln(φ)−(2−γln(φ)),
 V(Rn,0)∼112+π26ln(φ)2=7.1868910445...

as .

If consists of multus bitstrings, then we can talk both about -runs:

 G(z)=−z(1−z)(1−z+z2),
 Hk(z)=1+z2−zk−1−zk1−2z+z2−z3+zk+1z,H(z)=1+z21−2z+z2−z3z;
 num11=2z2+7z3+16z4+32z5+62z6+118z7+221z8+409z9+751z10+⋯
 num21=4z2+17z3+46z4+104z5+220z6+448z7+889z8+1729z9+3313z10+⋯

and -runs:

 G(z)=0,
 Hk(z)=1+z2−zk−1+zk−2zk+11−2z+z2−z3+zk+2z,H(z)=1+z21−2z+z2−z3z;
 num10=z+2z2+5z3+11z4+23z5+45z6+87z7+165z8+309z9+573z10+⋯,
 num20=z+4z2+11z3+27z4+63z5+135z6+281z7+565z8+1115z9+2161z10+⋯.

Letting

 ψ=13⎡⎢⎣2+(25+3√692)1/3+(25−3√692)1/3⎤⎥⎦=1.7548776662...,

it is conjectured that

 V(Rn,1)∼V(Rn,0)∼112+π26ln(ψ)2=5.2840019997...

as .

If consists of bimultus strings, there is symmetry (just as for the unconstrained case).  We have

 G(z)=−z(1−z+z2)2(1−z)(1−z+z3),
 Hk(z)=2−2z+2z2−zk−2+zk−1−2zk1−2z+z2−z4+zk+2z2,H(z)=2−2z+2z21−2z+z2−z4z2;
 num10=num11=2z2+3z3+8z4+15z5+28z6+50z7+87z8+150z9+255z10+⋯,
 num20=num21=4z2+9z3+24z4+51z5+102z6+196z7+361z8+656z9+1165z10+⋯.

It is conjectured that, up to small periodic fluctuations,

 E(Rn,0)∼E(Rn,1)∼ln(n)ln(φ)−(52−γln(φ)),
 V(Rn,0)∼V(Rn,1)∼112+π26ln(φ)2=7.1868910445...

as .  The same asymptotic variance occurred for solus bitstrings.

If consists of persolus strings, then it makes little sense to talk about -runs.  For -runs, we have

 G(z)=−z(1+z)21+z2,
 Hk(z)=1+2z2−zk−1−2zk1−z−z3+zk+1z,H(z)=1+2z21−z−z3z;
 num10=2z2+7z3+12z4+18z5+30z6+49z7+76z8+118z9+183z10+⋯,
 num20=4z2+17z3+38z4+70z5+128z6+227z7+384z8+636z9+1037z10+⋯.

Letting

 θ=13⎡⎢⎣1+(29+3√932)1/3+(29−3√932)1/3⎤⎥⎦=1.4655712318...,

it is conjectured that

 E(Rn,0)∼ln(n)ln(θ)−(52−γln(θ)),
 V(Rn,0)∼112+π26ln(θ)2=11.3414222234...

as .  The constants and also appeared in [8]; was called Moore’s constant in [10] and is the limit of a certain fundamental iteration.

## 4 Cross-Covariances I

Let us return to the unconstrained case.  Exhibiting in a manner parallel to old formulas in our introduction seems impossible: no analogous summation identity for apparently exists.  Thus new formulas are somewhat less tidy, but nevertheless workable.  The number of bitstrings with no runs of s and no runs of s has generating function

 fi,j(z)=1−zi−zj+zi+j1−2z+zi+1+zj+1−zi+j

hence

 E(Rn,0Rn,1)=1dn[zn]∞∑i=1∞∑j=1ij{fi+1,j+1(z)−fi,j+1(z)−fi+1,j(z)+fi,j(z)}

where .  The Taylor expansion of the numerator series for is

 2z2+10z3+34z4+96z5+248z6+604z7+1418z8+3240z9+7260z10+⋯

and the correlation coefficient

 ρ=E(Rn,0Rn,1)−E(Rn,0)E(Rn,1)√V(Rn,0)√V(Rn,1)

is prescribed numerically in Table 1 for .  These results complement those in [11].

For multus bitstrings, since s are clumped (but s are not necessarily so), the associated generating function

 fi,j(z)=1+z2−zi−1−zi−zj−1+zj−2zj+1+2zi+j−11−2z+z2−z3+zi+1+zj+2−zi+jz

is unsurprisingly asymmetric in and .  The associated Taylor expansion is

 4z3+16z4+45z5+106z6+232z7+484z8+977z9+1927z10+⋯

and, again, the corresponding is prescribed in Table 1.  Correlations are all negative but approach zero as increases.  We observe a slightly stronger dependency between and for multus strings than for unconstrained strings. Calculating for bimultus strings remains open.  Simulation suggests that dependence is greater still for the bimultus case.

Table 1: Correlation as a function of .

## 5 Cross-Covariances II

Let us return to the solus case.  Being isolated, each acts as barrier to gathering s; we wonder to what extent the (random) number of such walls affects the largest crowd size.  To calculate seems to be difficult.  The number of bitstrings with less than two s and no runs of s has generating function

 f2,k(z)=∞∑n=1anzn

(a polynomial!) with

 an=⎧⎪ ⎪⎨⎪ ⎪⎩n+1if 1≤n≤k−1,2k−nif k≤n≤2k−1,0otherwise

assuming .  For example,

 {an}2k−1n=1={2,3,4,5,6,7,7,6,5,4,3,2,1}

when .

The number of bitstrings with less than three s and no runs of s has generating function with

 an=⎧⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎩2−n2+n22if 1≤n≤k−1,an−1+k−2if k≤n≤k+2,an−1+3k−2n+2if k+3≤n≤2k,3k−n2+(3k−n)22if 2k+1≤n≤3k−1,0otherwise

assuming .  For example,

 {an}3k−1n=1={2,3,5,8,12,17,22,27,32,35,36,35,32,27,21,15,10,6,3,1}

when .

The number of bitstrings with less than four s and no runs of s has generating function with

 an=⎧⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎩2if n=1,1−δk,n+7(n−1)3−(n−1)22+(n−1)36if 2≤n≤k,an−1+u(k,n)if k+1≤n≤2k+2,an−1−v(k,n)if 2k+3≤n≤3k,4k−n3+(4k−n)22+(4k−n)36if 3k+1≤n≤4k−1,0otherwise

assuming , where

 u(k,n)=⎧⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪⎩−k2+(2n−5)k−w(n−k)2if % k+1≤n≤2k,2(n−k−3)if n=2k+1,0otherwise;
 v(k,n)=−20k2+(16n−30)k−(3n2−11n+12)2;
 w(m)=⎧⎪ ⎪⎨⎪ ⎪⎩−2if m=1,2if m=2,3m2−13m+20if m≥3;

is when and is otherwise.  For example,

 {an}4k−1n=1 ={2,3,5,8,13,21,32,47,67,91,118,145,169,187, 197,197,186,166,140,111,82,56,35,20,10,4,1}

when .

An expression for , the generating function corresponding to bitstrings with less than five s and no runs of s, exists but awaits simplication.  For example,

 {an}5k−1n=1 ={2,3,5,8,13,21,33,52,82,126,188,271,376,500,637,777,907,1013, 1081,1102,1073,997,882,741,590,444,314,207,126,70,35,15,5,1}

when .  For arbitrary , clearly is equal to

 4−δk,n−n−24+35(n−2)224−(n−2)34+(n−2)424

for and

 5k−n4+11(5k−n)224+(5k−n)34+(5k−n)424

for .  Also,

 an={an−1+u(k,n)if k+1≤n≤2k+1,an−1−v(k,n)if 3k+2≤n≤4k

where

 u(k,n)=δ2k+1,n+k3−(3n−12)k2+(3n2−24n+59)k−w(n−k)6;
 v(k,n)=3δ3k+2,n+−195k3+(165n−426)k2−(45n2−228n+309)k+(4n3−30n2+80n−72)6;
 w(m)=⎧⎪ ⎪⎨⎪ ⎪⎩54if m=1,30if 2≤m≤3,4m3−42m2+176m−240if m≥4;
 a3k+1=11k4−2k3−35k2−22k+7224;
 (index of max1≤n≤5k−1an)={[c]lll(5k+5)/2if k≥3 is odd,(5k+4)/2if k≥4 is even;
 (max1≤n≤5k−1an)=⎧⎨⎩(115k4−184k3−22k2−104k+387)/192if k≥3 is odd,(115k4−184k3−52k2+16k+192)/192if k≥2 is% even.\vskip12.0ptplus4.0ptminus4.0pt

The interval deserves more attention.  From the approximation

 ∞∑k=2k{f2,k+1(z)−f2,k(z)}+2∞∑k=2k{f3,k+1(z)−f2,k+1(z)−f3,k(z)+f2,k(z)} +3∞∑k=2k{f4,k+1(z)−f3,k+1(z)−f4,k(z)+f3,k(z)}+4∞∑k=2k{f5,k+1(z)−f4,k+1(z)−f5,k(z)+f4,k(z)}

we obtain the Taylor expansion of the numerator series for :

 2z2+7z3+18z4+43z5+94z6+196z7+392z8+764z9+1454z10+⋯

(every exhibited coefficient is correct).  We would need , , … to achieve the precision necessary to adequately estimate for large .  Simulation suggests that correlations are all negative but, unlike the previous section, tend to a nonzero quantity (possibly ?) as approaches infinity.  We have not yet attempted to study the persolus case.

## 6 Cross-Covariances III

This section is an addendum to the preceding.  A recent paper [12] gave an impressive recursion for the number of unconstrained bitstrings of length containing exactly s and a longest run of exactly s:

 Fn(x,y)=⎧⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎩y−1∑i=κFn−i−1(x−i,y)+y∑j=0Fn−y−1(x−y,j)if 1≤x≤n−2 and εn(x,y)=1,λn(y)if x=n−1 and εn(x,y)=1,0otherwise,
 Fn(0,0)=1−κ,Fn(n,n)=1

where ,

 εn(x,y)=⎧⎪ ⎪⎨⎪ ⎪⎩1if n≥2 % and ⌊nn−x+1⌋≤y≤x,0otherwise;
 λn(y)=⎧⎪⎨⎪⎩1if n is odd and y=n−12,2otherwise.

By a similar argument, we deduce the number of solus bitstrings of length containing exactly s and a longest run of exactly s:

 ˜Fn(x,y)={Fn−1(x,y)+Fn(x,y)if n≥2,δx,yotherwise

where is defined recursively as before, with the same but with and a different :

 λn(y)=⎧⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎩⎡⎢⎣1%ify=n−12 or y=n−1,2otherwiseif n is odd,[1if y=n−1,2otherwiseif n is even.

Consequently, the number of solus bitstrings of length with less than s and no runs of s is

 an=k−1∑y=0ℓ−1∑x=0˜Fn(n−x,y)

and our prior results for and are easily verified.  As more examples, we have

 {an}6k−1n=1 ={2,3,5,8,13,21,33,52,83,132,209,327,502