|
|
0 0 0 // false 0 0 1 // false 0 1 0 // true 0 1 1 // false 1 0 0 // true 1 0 1 // true 1 1 0 // true 1 1 1 // false |
0 0 0 // false 0 0 1 // false 0 1 0 // false 0 1 1 // true 1 0 0 // false 1 0 1 // false 1 1 0 // true 1 1 1 // true |
H H H T T H |
Heads followed by Tails 0 0 FALSE 2 0 1 FALSE 1 1 0 TRUE 1 1 FALSE 1 2 Heads 0 0 FALSE 2 0 1 FALSE 1 1 0 FALSE 2 1 1 TRUE |
Initial H/T T/H H/H T/T T T 2 1 2 0 T H 1 0 1 2 H T 0 1 2 1 H H 1 2 0 2 4 4 5 5 |
H/T H/H Calc H/T 2: 0.24997010 0.24968540 0.25000000 3: 0.24996640 0.12506610 0.25000000 4: 0.18758660 0.12509210 0.18750000 5: 0.12521370 0.09383590 0.12500000 6: 0.07802730 0.07825540 0.07812500 7: 0.04681720 0.06250200 0.04687500 8: 0.02722800 0.05079730 0.02734375 9: 0.01565420 0.04104690 0.01562500 10: 0.00879530 0.03317260 0.00878906 11: 0.00489330 0.02684240 0.00488281 12: 0.00268190 0.02166540 0.00268555 13: 0.00145320 0.01761750 0.00146484 14: 0.00079530 0.01421150 0.00079346 15: 0.00042320 0.01147650 0.00042725 16: 0.00023020 0.00930500 0.00022888 17: 0.00012510 0.00749300 0.00012207 18: 0.00006890 0.00609530 0.00006485 19: 0.00003100 0.00493780 0.00003433 20: 0.00001740 0.00398690 0.00001812 21: 0.00001070 0.00321360 0.00000954 22: 0.00000490 0.00260350 0.00000501 23: 0.00000260 0.00212170 0.00000262 24: 0.00000180 0.00171860 0.00000137 25: 0.00000090 0.00139080 0.00000072 26: 0.00000050 0.00111850 0.00000037 27: 0.00000020 0.00090150 0.00000019 28: 0.00000010 0.00073300 0.00000010 29: 0.00000000 0.00059400 0.00000005 30: 0.00000000 0.00047920 0.00000003 |
|
|
@doug4, I see what you're saying, and clearly that must be the reason. Still very unintuitive, though. I don't think I'll ever quite wrap my head around it. |
H/T Calc H/T H/H Calc H/H 2: 0.25038310 0.25000000 0.25024300 0.25000000 3: 0.24973450 0.25000000 0.12482450 0.12500000 4: 0.18740790 0.18750000 0.12484490 0.12500000 5: 0.12505620 0.12500000 0.09373750 0.09375000 6: 0.07814610 0.07812500 0.07802830 0.07812500 7: 0.04688520 0.04687500 0.06250910 0.06250000 8: 0.02735100 0.02734375 0.05081590 0.05078125 9: 0.01559380 0.01562500 0.04103470 0.04101562 10: 0.00876260 0.00878906 0.03320470 0.03320312 11: 0.00483490 0.00488281 0.02689730 0.02685547 12: 0.00267300 0.00268555 0.02175960 0.02172852 13: 0.00145270 0.00146484 0.01758170 0.01757812 14: 0.00080290 0.00079346 0.01425310 0.01422119 15: 0.00043280 0.00042725 0.01150860 0.01150513 16: 0.00022150 0.00022888 0.00930060 0.00930786 17: 0.00012710 0.00012207 0.00759860 0.00753021 18: 0.00006490 0.00006485 0.00611180 0.00609207 19: 0.00003590 0.00003433 0.00493320 0.00492859 20: 0.00001590 0.00001812 0.00396850 0.00398731 21: 0.00000930 0.00000954 0.00320870 0.00322580 22: 0.00000440 0.00000501 0.00257890 0.00260973 23: 0.00000210 0.00000262 0.00211540 0.00211132 24: 0.00000110 0.00000137 0.00170780 0.00170809 25: 0.00000100 0.00000072 0.00136280 0.00138187 26: 0.00000000 0.00000037 0.00112250 0.00111796 27: 0.00000000 0.00000019 0.00091390 0.00090445 28: 0.00000010 0.00000010 0.00073700 0.00073171 29: 0.00000000 0.00000005 0.00059610 0.00059197 30: 0.00000000 0.00000003 0.00048000 0.00047891 31: 0.00000000 0.00000001 0.00038940 0.00038745 32: 0.00000000 0.00000001 0.00031520 0.00031345 33: 0.00000000 0.00000000 0.00024970 0.00025359 34: 0.00000000 0.00000000 0.00020980 0.00020516 35: 0.00000000 0.00000000 0.00016330 0.00016598 36: 0.00000000 0.00000000 0.00013250 0.00013428 37: 0.00000000 0.00000000 0.00010470 0.00010863 38: 0.00000000 0.00000000 0.00008470 0.00008789 39: 0.00000000 0.00000000 0.00007130 0.00007110 40: 0.00000000 0.00000000 0.00006020 0.00005752 41: 0.00000000 0.00000000 0.00004570 0.00004654 42: 0.00000000 0.00000000 0.00003840 0.00003765 43: 0.00000000 0.00000000 0.00003030 0.00003046 44: 0.00000000 0.00000000 0.00002290 0.00002464 45: 0.00000000 0.00000000 0.00001940 0.00001994 46: 0.00000000 0.00000000 0.00001640 0.00001613 47: 0.00000000 0.00000000 0.00001410 0.00001305 48: 0.00000000 0.00000000 0.00001040 0.00001056 49: 0.00000000 0.00000000 0.00000810 0.00000854 50: 0.00000000 0.00000000 0.00000700 0.00000691 ... Expectations: 3.99887870 4.00000000 6.00064220 5.99999355 (lines 51 to 78 elided) |
|
|
The difference comes when you fail to match on the succeeding throw. When you are looking for H/T, a failure means you are now sitting on a H, so you still need to only throw a T. If you are looking for H/H, a failure means you are sitting on a T, and you need to throw the first H again. So after you attain your first match, a failure on the subsequent throw differs between still needing to match the second or having to start over. |
@lastchance, The Fibonacci series?! How do you figure this shit out! Anyway, here's the result. It's a perfect fit. |
Total number of sequences of length n in H and T is 2^n. Each probability is: number satisfying criterion P(n) = --------------------------- total number (= 2^n) The criterion is that the sequence ends in HH. Edge case n=2: single sequence HH, P(2) = 1/2^2 = 1/4 Edge case n=3: single sequence THH, P(3) = 1/2^3 = 1/8 All others are of form: (n-3 values with no consecutive H's) | THH (*) Let C(m) = count of sequences of length m with no consecutive H's (the left side of (*) with m = n - 3) Ordering by first H: TT ... T (m T's; no H's) HT | (C(m-2) sequences) THT | (C(m-3) sequences) . . . TT ... THT | (C(0) = 1) TT ... TTH | (C(-1) = 1) Then C(m) = 1 + C(m-2) + C(m-3) + ... + C(0) + C(-1) m >= 2 C(m-1) = 1 + C(m-3) + ... + C(0) + C(-1) m >= 3 Subtract: C(m) - C(m-1) = C(m-2) (for m >= 3) therefore C(m) = C(m-1) + C(m-2) Fibonacci type But C(-1) = 1, C(0) = 1, C(1) = 2, ... and F(1) = 1, F(2) = 1, F(3) = 2, ... Hence, C(m) = F(m+2) Then from (*), P(n) = C(n-3)/2^n = F(n-1)/2^n Checking shows that it also works for the edge cases. |
Ordering by first H: |TT .....................TT| (m T's; no H's) |HT | (C(m-2) sequences) | |THT | (C(m-3) sequences) | . . |TTTTT ......THT| C(1) seq | |TTTTTTT................THT| |TTTTTTTTT...............TH| Then C(m) = 1 + C(m-2) + C(m-3) + ... + 1 + 1 m >= 2 C(m-1) = 1 + C(m-3) + ... + 1 + 1 m >= 3 |