Sample point TH TTH HTH TTTH HTTH HHTH TTTTH HTTTH HHTTH HHHTH in Java Encoder QR Code ISO/IEC18004 in Java Sample point TH TTH HTH TTTH HTTH HHTH TTTTH HTTTH HHTTH HHHTH Table 75 Sample point TH TTH HTH TTTH HTTH HHTH TTTTH HTTTH HHTTH HHHTH Reading Quick Response Code In JavaUsing Barcode Control SDK for Java Control to generate, create, read, scan barcode image in Java applications.Expected Waiting Time for TH QR Code JIS X 0510 Creation In JavaUsing Barcode maker for Java Control to generate, create QR Code image in Java applications.This observation makes the sample space fairly easy to write out and it also makes the calculation of probabilities fairly simple Note that the probability of any sample point has the factor qp for the sequence TH at the nth toss If the sample point begins with no heads, then its probability has a factor of qn 2 If the sample point begins with H, then its probability has a factor of pqn 3 If the sample point begins with HH, then its probability has a factor of p2 qn 4 This pattern continues until we come to the sample point with n 2 H s followed by TH The probability of this point has a factor of pn 2 Consider the case for n = 5 shown in the sample space above The probabilities of the points add to qp(q3 + pq2 + p2 q + p3 ) This can be recognized as qp(q4 p4 )/(q p) This pattern continues, and by letting X denote the total number of tosses necessary, we nd that P(X = n) = qp(qn 1 pn 1 ) q p for n = 2, 3, 4, QR-Code Recognizer In JavaUsing Barcode scanner for Java Control to read, scan read, scan image in Java applications.The formula would not work for q = p = 1/2 In that case the sample points are equally likely, each having probability (1/2)n and, as we have seen, there are n 1 of them It follows in the case where q = p = 1/2 that P(X = n) = n 1 2n for n = 2, 3, 4, Generating Bar Code In JavaUsing Barcode generation for Java Control to generate, create bar code image in Java applications.EXPECTED WAITING TIME FOR TH Barcode Recognizer In JavaUsing Barcode recognizer for Java Control to read, scan read, scan image in Java applications.Using the formula above,Make QR Code In C#Using Barcode drawer for Visual Studio .NET Control to generate, create QR-Code image in VS .NET applications.E[N] =QR-Code Encoder In Visual Studio .NETUsing Barcode printer for ASP.NET Control to generate, create QR Code ISO/IEC18004 image in ASP.NET applications.qp(qn 1 pn 1 ) q p QR Code JIS X 0510 Generation In .NET FrameworkUsing Barcode drawer for Visual Studio .NET Control to generate, create Quick Response Code image in Visual Studio .NET applications.To calculate this sum, consider Making QR Code ISO/IEC18004 In VB.NETUsing Barcode generator for .NET Control to generate, create QR Code JIS X 0510 image in .NET framework applications.n qn 1 = 2q + 3q2 + 4q3 + Code 128A Creator In JavaUsing Barcode creator for Java Control to generate, create USS Code 128 image in Java applications. 7 UPC - 13 Maker In JavaUsing Barcode generation for Java Control to generate, create EAN-13 image in Java applications.Waiting Time Problems Bar Code Creation In JavaUsing Barcode maker for Java Control to generate, create barcode image in Java applications.Now S + 1 = 1 + 2q + 3q2 + 4q3 + and we have seen that the left-hand side of this equation is 1/p2 So S = 1/p2 1 E[N] = 1 qp 1 q p p2 1 1 q2 = 1 qpUPCE Drawer In JavaUsing Barcode creation for Java Control to generate, create UPC-E Supplement 2 image in Java applications.The formula above applies only if p = q In the case p = q,we rst consider / P(X = n + 1) n = P(X = n) 2(n 1) SoCode 39 Extended Drawer In Visual C#Using Barcode generator for Visual Studio .NET Control to generate, create Code-39 image in VS .NET applications.2(n 1)P(X = n + 1) =UPC Code Creation In .NETUsing Barcode drawer for ASP.NET Control to generate, create UPC-A Supplement 5 image in ASP.NET applications.n=2 n=2 Encode DataMatrix In VB.NETUsing Barcode printer for Visual Studio .NET Control to generate, create Data Matrix 2d barcode image in VS .NET applications.nP(X = n)Encoding Bar Code In .NETUsing Barcode generator for .NET framework Control to generate, create bar code image in VS .NET applications.We can write this as Bar Code Drawer In C#.NETUsing Barcode encoder for .NET framework Control to generate, create barcode image in .NET framework applications.[(n + 1) 2]P(X = n + 1) =Reading Bar Code In JavaUsing Barcode decoder for Java Control to read, scan read, scan image in Java applications.nP(X = n)Bar Code Creation In VS .NETUsing Barcode creator for ASP.NET Control to generate, create bar code image in ASP.NET applications.and from this it follows that 2E[N] 4 = E[N] so E[N] = 4 This may be a surprise We found that the average waiting time for HH with a fair coin is six (By symmetry, the average waiting time for TT is six tosses and the average waiting time for HT is four tosses) There is apparently no intuitive reason for this to be so, but these results can easily be veri ed by simulation to provide some evidence that they are correct We will simply state the average waiting times for each of the patterns of length 3 with a fair coin in Table 76Table 76 Pattern HHH THH HTH TTH THT HTT HHT TTT Average waiting time 14 8 10 8 10 8 8 14 We continue this chapter with an intriguing game AN UNFAIR GAME WITH A FAIR COIN Here is a game with a fair coin In fact, it is an unfair game with a fair coin!Three Tosses Consider the patterns HH, TH, HT , and TT for two tosses of a fair coin If you choose one of these patterns, I will choose another and then we toss a fair coin until one of these patterns occurs The winner is the person who chose the rstoccurring pattern For example, if you choose HH, I will choose TH If we see the sequence HTTTTH, then I win since the pattern TH occurred before the pattern HH My probability of beating you is 3/4! Here is why If the rst two tosses are HH, you win If the rst two tosses are TH, I win If the rst two tosses are HT then this can be followed by any number of T s, but eventually H will occur and I win If the rst two tosses are TT then this can be followed by any number of T s but eventually H will occur and I will win If you are to win, you must toss HH on the rst two tosses; this is the only way you can win and it has probability 1/4 If a T is tossed at any time, I will win, so my probability of winning is 3/4 The fact that the patterns HH, TH, HT , and TT are equally likely for a fair coin may be observed by a game player who may think that any choice is equally good is irrelevant; the choice of pattern is crucial, as is the fact that he is allowed to make the rst choice If you choose TT , then the only way you can win is by tossing two tails on the rst two tosses I will choose HT and I will win 3/4 of the time A sensible choice for you is either TH or HT, and then my probability of beating you is only 1/2 If we consider patterns with three tosses, as shown in the table above, my minimum probability of beating you is 2/3! (And if you do not choose well, I can increase that probability to 3/4 or 7/8!) This can be tried by simulation It is puzzling to note that no matter what pattern you choose, I will probably beat you This means that if we play the game twice, and I win in the rst game, then you can choose the pattern I chose on the rst game, and I can still probably beat you Probabilities then are not transitive, so if pattern A beats pattern B and pattern B beats pattern C, then it does not follow that pattern A will necessarily beat pattern C