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.

The relevant derivatives are<br />

F’(1) = 5 - (1 +pq2)/p2q3,<br />

F”(1) = 20 - 6pq2/p2q3 ;<br />

and if X is the number of flips we get<br />

EX = Mean(G) = 5-Mean(F) := pP2qm3 +pmlqP1;<br />

VX = Var(G) = -Var(F)<br />

8.4 FLIPPING COINS 393<br />

(8.71)<br />

= -25+pP2q 3 + 7p ‘q--l +Mean(F)’<br />

= (EX)2 -9~~ 2qP” - 3pP’qm’ , (8.72)<br />

When p = 5, the mean and variance are 36 and 996.<br />

Let’s get general: The problem we have just solved was “random” enough<br />

to show us how to analyze the case that we are waiting <strong>for</strong> the first appearance<br />

of an arbitrary pattern A of heads and tails. Again we let S be the sum of<br />

all winning sequences of H's and T’s, and we let N be the sum of all sequences<br />

that haven’t encountered the pattern A yet. Equation (8.67) will remain the<br />

same; equation (8.68) will become<br />

NA = s(l + A”) [A(“-‘, =A,,_,,] + A(21 [A’m 2) =A(,- 2,]<br />

+.,.$-Aim "[A~'-Ac,i]), (8.73)<br />

where m is the length of A, and where ACkl and Aiki denote respectively the<br />

last k characters and the first k characters of A. For example, if A is the<br />

pattern THTTH we just studied, we have<br />

Ai” = H, Al21 = TH, Ai31 = TTH, Ai41 = HTTH.<br />

A,,, = T, 42, = TH, A(3) = THT, A,,, = THTT:<br />

Since the only perfect match is Ai21 = A ,l), equation (8.73) reduces to (8.68).<br />

Let A be the result of substituting p-’ <strong>for</strong> H and qm’ <strong>for</strong> T in the pattern<br />

A. Then it is not difficult to generalize our derivation of (8.71) and (8.72)<br />

to conclude (exercise 20) that the general mean and variance are<br />

EX = T A/k, [Alk) =A/k,] ; (8.74)<br />

k=l<br />

w = (EX)2 - f (2k- l&k) [ACk’ =A[k)] . (8.75)<br />

k=l

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

Saved successfully!

Ooh no, something went wrong!