Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Runs and Sequences

by tlm (Prior)
on Sep 09, 2005 at 17:54 UTC ( [id://490681]=note: print w/replies, xml ) Need Help??


in reply to Runs and Sequences

If you know the expectation value of the number of flips sn required to first obtain a run of length n, then sn+1 is given by

sn+1 = 2 sn + 1
That's because once you hit a run of length n the next flip has a 50% probability of extending the run by one. So on average you'll need twice as many flips for a run of length n+1 than for a run of length n, plus an extra one (the n+1st flip in the run).

Clearly, s1 = 1. Therefore, s2 = 3, s3 = 7. In fact it is easy to show by induction that

sn = 2n − 1
because it's true for n = 1, and, by the recurrence above
2 (2n − 1) + 1 = 2n+1 − 1

Therefore, on average, to get a run of length 16 you'll need 216 − 1 = 65535 flips.

The question of what is the expectation value of the longest run in a fixed number s of flips is a harder one. I don't know of an exact expression for it, but the naive idea of solving for n gets one pretty close: log 2 (n + 1). (Usually the added 1 is omitted, since n is assumed to be large.)

the lowliest monk

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://490681]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-25 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found