09.12.2012 Views

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

392 DISCRETE PROBABILITY<br />

But the coin-flipping problem can be solved in a much simpler way,<br />

without the complexities of the general finite-state approach. Instead of six<br />

equations in six unknowns SO, S, , . , . , Ss, we can characterize S with only<br />

two equations in two unknowns. The trick is to consider the auxiliary sum<br />

N = SO + S1 + SJ + S3 + Sq of all flip sequences that don’t contain any occurrences<br />

of the given pattern THTTH:<br />

We have<br />

N = 1 + H + T + HH + . . . + THTHT + THTTT + .<br />

l+N(H+T) = N+S, (8.67)<br />

because every term on the left either ends with THTTH (and belongs to S) or<br />

doesn’t (and belongs to N); conversely, every term on the right is either empty<br />

or belongs to N H or N T. And we also have the important additional equation<br />

NTHTTH = S+STTH, (8.68)<br />

because every term on the left completes a term of S after either the first H<br />

or the second H, and because every term on the right belongs to the left.<br />

The solution to these two simultaneous equations is easily obtained: We<br />

have N = (1 - S)( 1 - H - T) ’ from (&X67), hence<br />

(1 -S)(l -T-H) ‘THTTH = S(1 +TTH).<br />

As be<strong>for</strong>e, we get the probability generating function G(Z) <strong>for</strong> the number of<br />

flips if we replace H by pz and T by qz. A bit of simplification occurs since<br />

p+q=l,andwefind<br />

(1 - G(z))p2q3t5<br />

1-Z<br />

hence the solution is<br />

G(z) =<br />

= G(z)(l +pqV);<br />

p2q’;z5<br />

p2q325 + (1 +pqV)(l - 2)<br />

(8.69)<br />

Notice that G( 1) = 1, if pq # 0; we do eventually encounter the pattern<br />

THTTH, with probability 1, unless the coin is rigged so that it always comes<br />

up heads or always tails.<br />

To get the mean and variance of the distribution (8.6g), we invert G(z)<br />

as we did in the previous problem, writing G(z) = z5/F(z) where F is a polynomial:<br />

F(z) =<br />

p2q3z5+ (1 +pq2z3)(1 - 2)<br />

p2q3<br />

(8.70)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!