You are not logged in.
Pages: 1
I compared the values (1/2), (1/3)..., (1/20) and got (no surprises) the values of
log(1+(1/2)), log(1+(1/3))...log(1+(1/20)) for a[0].
It will be interesting to see if this works for other Taylor expansions (e.g., sin(x), exp(x), etc.).
If a[n-1] = (1/8) * ( (1/n) - a[n] ) and I start from a[3] and iterate to a[0], here's what I get:
a[0] = (1/8) * ( 1 - (1/8) * ( (1/2) - (1/8) * ( (1/3) - a[3] ))))))...)))))
The coefficient of the "1" is 1/8.
The coefficient of the "1/2" is -(1/8)^2
The coefficient of the "1/3" is (1/8)^3
The Taylor expansion of ln(1+x) = x - (1/2)*x^2 + (1/3)*x^3...
So when x=1/8, for a[0] these 2 series are the same.
Thank you for showing that to me. Yes, it is beautiful.
In essence, the iterations generate the Taylor series expansion for ln(1+(1/8)). Is this correct? If so, this explains why you have the 1/n term. For exp(x), that term would have to be 1/n!, and you shouldn't need the minus sign....?
Amazing! I confirm this for 2 starting values and 2 iteration lengths (listed below).
Although I can believe that errors will grow smaller and smaller when the coefficient is less than 1, it isn't obvious to me why the sequence values are asserting themselves so strongly. But clearly they do...
a[ 51] = 1.00000e+03 (1000)
a[50] = -1.24998e+02 (-124.998)
a[49] = 1.56272e+01 (15.6272)
a[48] = -1.95085e+00 (-1.95085)
a[47] = 2.46460e-01 (0.24646)
a[46] = -2.81479e-02 (-0.0281479)
a[45] = 6.23588e-03 (0.00623588)
a[44] = 1.99829e-03 (0.00199829)
a[43] = 2.59112e-03 (0.00259112)
a[42] = 2.58309e-03 (0.00258309)
a[41] = 2.65330e-03 (0.0026533)
a[40] = 2.71712e-03 (0.00271712)
a[39] = 2.78536e-03 (0.00278536)
a[38] = 2.85696e-03 (0.00285696)
a[37] = 2.93235e-03 (0.00293235)
a[36] = 3.01183e-03 (0.00301183)
a[35] = 3.09574e-03 (0.00309574)
a[34] = 3.18446e-03 (0.00318446)
a[33] = 3.27841e-03 (0.00327841)
a[32] = 3.37808e-03 (0.00337808)
a[31] = 3.48399e-03 (0.00348399)
a[30] = 3.59676e-03 (0.00359676)
a[29] = 3.71707e-03 (0.00371707)
a[28] = 3.84571e-03 (0.00384571)
a[27] = 3.98357e-03 (0.00398357)
a[26] = 4.13168e-03 (0.00413168)
a[25] = 4.29123e-03 (0.00429123)
a[24] = 4.46360e-03 (0.0044636)
a[23] = 4.65038e-03 (0.00465038)
a[22] = 4.85348e-03 (0.00485348)
a[21] = 5.07513e-03 (0.00507513)
a[20] = 5.31799e-03 (0.00531799)
a[19] = 5.58525e-03 (0.00558525)
a[18] = 5.88079e-03 (0.00588079)
a[17] = 6.20935e-03 (0.00620935)
a[16] = 6.57677e-03 (0.00657677)
a[15] = 6.99040e-03 (0.0069904)
a[14] = 7.45953e-03 (0.00745953)
a[13] = 7.99613e-03 (0.00799613)
a[12] = 8.61587e-03 (0.00861587)
a[11] = 9.33968e-03 (0.00933968)
a[10] = 1.01962e-02 (0.0101962)
a[ 9] = 1.12255e-02 (0.0112255)
a[ 8] = 1.24857e-02 (0.0124857)
a[ 7] = 1.40643e-02 (0.0140643)
a[ 6] = 1.60991e-02 (0.0160991)
a[ 5] = 1.88209e-02 (0.0188209)
a[ 4] = 2.26474e-02 (0.0226474)
a[ 3] = 2.84191e-02 (0.0284191)
a[ 2] = 3.81143e-02 (0.0381143)
a[ 1] = 5.77357e-02 (0.0577357)
a[ 0] = 1.17783e-01 (0.117783)
a[ 51] = 5.55500e+03 (5555)
a[50] = -6.94373e+02 (-694.373)
a[49] = 8.67991e+01 (86.7991)
a[48] = -1.08473e+01 (-10.8473)
a[47] = 1.35852e+00 (1.35852)
a[46] = -1.67156e-01 (-0.167156)
a[45] = 2.36118e-02 (0.0236118)
a[44] = -1.73701e-04 (-0.000173701)
a[43] = 2.86262e-03 (0.00286262)
a[42] = 2.54915e-03 (0.00254915)
a[41] = 2.65755e-03 (0.00265755)
a[40] = 2.71659e-03 (0.00271659)
a[39] = 2.78543e-03 (0.00278543)
a[38] = 2.85695e-03 (0.00285695)
a[37] = 2.93235e-03 (0.00293235)
a[36] = 3.01183e-03 (0.00301183)
a[35] = 3.09574e-03 (0.00309574)
a[34] = 3.18446e-03 (0.00318446)
a[33] = 3.27841e-03 (0.00327841)
a[32] = 3.37808e-03 (0.00337808)
a[31] = 3.48399e-03 (0.00348399)
a[30] = 3.59676e-03 (0.00359676)
a[29] = 3.71707e-03 (0.00371707)
a[28] = 3.84571e-03 (0.00384571)
a[27] = 3.98357e-03 (0.00398357)
a[26] = 4.13168e-03 (0.00413168)
a[25] = 4.29123e-03 (0.00429123)
a[24] = 4.46360e-03 (0.0044636)
a[23] = 4.65038e-03 (0.00465038)
a[22] = 4.85348e-03 (0.00485348)
a[21] = 5.07513e-03 (0.00507513)
a[20] = 5.31799e-03 (0.00531799)
a[19] = 5.58525e-03 (0.00558525)
a[18] = 5.88079e-03 (0.00588079)
a[17] = 6.20935e-03 (0.00620935)
a[16] = 6.57677e-03 (0.00657677)
a[15] = 6.99040e-03 (0.0069904)
a[14] = 7.45953e-03 (0.00745953)
a[13] = 7.99613e-03 (0.00799613)
a[12] = 8.61587e-03 (0.00861587)
a[11] = 9.33968e-03 (0.00933968)
a[10] = 1.01962e-02 (0.0101962)
a[ 9] = 1.12255e-02 (0.0112255)
a[ 8] = 1.24857e-02 (0.0124857)
a[ 7] = 1.40643e-02 (0.0140643)
a[ 6] = 1.60991e-02 (0.0160991)
a[ 5] = 1.88209e-02 (0.0188209)
a[ 4] = 2.26474e-02 (0.0226474)
a[ 3] = 2.84191e-02 (0.0284191)
a[ 2] = 3.81143e-02 (0.0381143)
a[ 1] = 5.77357e-02 (0.0577357)
a[ 0] = 1.17783e-01 (0.117783)
a[ 71] = 5.55500e+03 (5555)
a[70] = -6.94373e+02 (-694.373)
a[69] = 8.67984e+01 (86.7984)
a[68] = -1.08480e+01 (-10.848)
a[67] = 1.35784e+00 (1.35784)
a[66] = -1.67864e-01 (-0.167864)
a[65] = 2.28769e-02 (0.0228769)
a[64] = -9.36541e-04 (-0.000936541)
a[63] = 2.07019e-03 (0.00207019)
a[62] = 1.72535e-03 (0.00172535)
a[61] = 1.80046e-03 (0.00180046)
a[60] = 1.82412e-03 (0.00182412)
a[59] = 1.85532e-03 (0.00185532)
a[58] = 1.88673e-03 (0.00188673)
a[57] = 1.91933e-03 (0.00191933)
a[56] = 1.95307e-03 (0.00195307)
a[55] = 1.98801e-03 (0.00198801)
a[54] = 2.02423e-03 (0.00202423)
a[53] = 2.06179e-03 (0.00206179)
a[52] = 2.10077e-03 (0.00210077)
a[51] = 2.14125e-03 (0.00214125)
a[50] = 2.18332e-03 (0.00218332)
a[49] = 2.22708e-03 (0.00222708)
a[48] = 2.27263e-03 (0.00227263)
a[47] = 2.32009e-03 (0.00232009)
a[46] = 2.36956e-03 (0.00236956)
a[45] = 2.42120e-03 (0.0024212)
a[44] = 2.47513e-03 (0.00247513)
a[43] = 2.53152e-03 (0.00253152)
a[42] = 2.59054e-03 (0.00259054)
a[41] = 2.65237e-03 (0.00265237)
a[40] = 2.71723e-03 (0.00271723)
a[39] = 2.78535e-03 (0.00278535)
a[38] = 2.85696e-03 (0.00285696)
a[37] = 2.93235e-03 (0.00293235)
a[36] = 3.01183e-03 (0.00301183)
a[35] = 3.09574e-03 (0.00309574)
a[34] = 3.18446e-03 (0.00318446)
a[33] = 3.27841e-03 (0.00327841)
a[32] = 3.37808e-03 (0.00337808)
a[31] = 3.48399e-03 (0.00348399)
a[30] = 3.59676e-03 (0.00359676)
a[29] = 3.71707e-03 (0.00371707)
a[28] = 3.84571e-03 (0.00384571)
a[27] = 3.98357e-03 (0.00398357)
a[26] = 4.13168e-03 (0.00413168)
a[25] = 4.29123e-03 (0.00429123)
a[24] = 4.46360e-03 (0.0044636)
a[23] = 4.65038e-03 (0.00465038)
a[22] = 4.85348e-03 (0.00485348)
a[21] = 5.07513e-03 (0.00507513)
a[20] = 5.31799e-03 (0.00531799)
a[19] = 5.58525e-03 (0.00558525)
a[18] = 5.88079e-03 (0.00588079)
a[17] = 6.20935e-03 (0.00620935)
a[16] = 6.57677e-03 (0.00657677)
a[15] = 6.99040e-03 (0.0069904)
a[14] = 7.45953e-03 (0.00745953)
a[13] = 7.99613e-03 (0.00799613)
a[12] = 8.61587e-03 (0.00861587)
a[11] = 9.33968e-03 (0.00933968)
a[10] = 1.01962e-02 (0.0101962)
a[ 9] = 1.12255e-02 (0.0112255)
a[ 8] = 1.24857e-02 (0.0124857)
a[ 7] = 1.40643e-02 (0.0140643)
a[ 6] = 1.60991e-02 (0.0160991)
a[ 5] = 1.88209e-02 (0.0188209)
a[ 4] = 2.26474e-02 (0.0226474)
a[ 3] = 2.84191e-02 (0.0284191)
a[ 2] = 3.81143e-02 (0.0381143)
a[ 1] = 5.77357e-02 (0.0577357)
a[ 0] = 1.17783e-01 (0.117783)
a[ 71] = 1.00000e+00 (1)
a[70] = -1.23239e-01 (-0.123239)
a[69] = 1.71906e-02 (0.0171906)
a[68] = -3.37236e-04 (-0.000337236)
a[67] = 1.88039e-03 (0.00188039)
a[66] = 1.63062e-03 (0.00163062)
a[65] = 1.69011e-03 (0.00169011)
a[64] = 1.71181e-03 (0.00171181)
a[63] = 1.73915e-03 (0.00173915)
a[62] = 1.76673e-03 (0.00176673)
a[61] = 1.79529e-03 (0.00179529)
a[60] = 1.82477e-03 (0.00182477)
a[59] = 1.85524e-03 (0.00185524)
a[58] = 1.88674e-03 (0.00188674)
a[57] = 1.91933e-03 (0.00191933)
a[56] = 1.95307e-03 (0.00195307)
a[55] = 1.98801e-03 (0.00198801)
a[54] = 2.02423e-03 (0.00202423)
a[53] = 2.06179e-03 (0.00206179)
a[52] = 2.10077e-03 (0.00210077)
a[51] = 2.14125e-03 (0.00214125)
a[50] = 2.18332e-03 (0.00218332)
a[49] = 2.22708e-03 (0.00222708)
a[48] = 2.27263e-03 (0.00227263)
a[47] = 2.32009e-03 (0.00232009)
a[46] = 2.36956e-03 (0.00236956)
a[45] = 2.42120e-03 (0.0024212)
a[44] = 2.47513e-03 (0.00247513)
a[43] = 2.53152e-03 (0.00253152)
a[42] = 2.59054e-03 (0.00259054)
a[41] = 2.65237e-03 (0.00265237)
a[40] = 2.71723e-03 (0.00271723)
a[39] = 2.78535e-03 (0.00278535)
a[38] = 2.85696e-03 (0.00285696)
a[37] = 2.93235e-03 (0.00293235)
a[36] = 3.01183e-03 (0.00301183)
a[35] = 3.09574e-03 (0.00309574)
a[34] = 3.18446e-03 (0.00318446)
a[33] = 3.27841e-03 (0.00327841)
a[32] = 3.37808e-03 (0.00337808)
a[31] = 3.48399e-03 (0.00348399)
a[30] = 3.59676e-03 (0.00359676)
a[29] = 3.71707e-03 (0.00371707)
a[28] = 3.84571e-03 (0.00384571)
a[27] = 3.98357e-03 (0.00398357)
a[26] = 4.13168e-03 (0.00413168)
a[25] = 4.29123e-03 (0.00429123)
a[24] = 4.46360e-03 (0.0044636)
a[23] = 4.65038e-03 (0.00465038)
a[22] = 4.85348e-03 (0.00485348)
a[21] = 5.07513e-03 (0.00507513)
a[20] = 5.31799e-03 (0.00531799)
a[19] = 5.58525e-03 (0.00558525)
a[18] = 5.88079e-03 (0.00588079)
a[17] = 6.20935e-03 (0.00620935)
a[16] = 6.57677e-03 (0.00657677)
a[15] = 6.99040e-03 (0.0069904)
a[14] = 7.45953e-03 (0.00745953)
a[13] = 7.99613e-03 (0.00799613)
a[12] = 8.61587e-03 (0.00861587)
a[11] = 9.33968e-03 (0.00933968)
a[10] = 1.01962e-02 (0.0101962)
a[ 9] = 1.12255e-02 (0.0112255)
a[ 8] = 1.24857e-02 (0.0124857)
a[ 7] = 1.40643e-02 (0.0140643)
a[ 6] = 1.60991e-02 (0.0160991)
a[ 5] = 1.88209e-02 (0.0188209)
a[ 4] = 2.26474e-02 (0.0226474)
a[ 3] = 2.84191e-02 (0.0284191)
a[ 2] = 3.81143e-02 (0.0381143)
a[ 1] = 5.77357e-02 (0.0577357)
a[ 0] = 1.17783e-01 (0.117783)
I agree that if the coefficient is less than 1, the error will get smaller and smaller. So rewriting the recurrence as you have does that wonderfully.
However we've lost a[0] - the starting point. It's not obvious to me where you start. If you assume the existence of a fixed point (for n going to infinity), you can solve for the fixed point, but I don't see how to get back down to finite n.
So what do you do?
So far so good. Yes, the e*8^n will grow huge after many iterations and swamp out your signal. So how do you avoid this without resorting to doing things analytically?
I'm interpreting your remarks to mean ln(9/8) is just some number that is irrational (so it can't be represented exactly in a finite number of bits), and the 8 coefficient is just some number greater than 1. With any coefficient greater than 1, continued iteration with lead that to grow and grow and grow.
These are results from a 16-bit machine, double precision.
a[ 0] = 1.17783e-01 (0.117783)
a[ 1] = 5.77357e-02 (0.0577357)
a[ 2] = 3.81143e-02 (0.0381143)
a[ 3] = 2.84191e-02 (0.0284191)
a[ 4] = 2.26474e-02 (0.0226474)
a[ 5] = 1.88209e-02 (0.0188209)
a[ 6] = 1.60991e-02 (0.0160991)
a[ 7] = 1.40643e-02 (0.0140643)
a[ 8] = 1.24857e-02 (0.0124857)
a[ 9] = 1.12255e-02 (0.0112255)
a[10] = 1.01962e-02 (0.0101962)
a[11] = 9.33967e-03 (0.00933967)
a[12] = 8.61595e-03 (0.00861595)
a[13] = 7.99547e-03 (0.00799547)
a[14] = 7.46481e-03 (0.00746481)
a[15] = 6.94820e-03 (0.0069482)
a[16] = 6.91438e-03 (0.00691438)
a[17] = 3.50851e-03 (0.00350851)
a[18] = 2.74874e-02 (0.0274874)
a[19] = -1.67268e-01 (-0.167268)
a[20] = 1.38814e+00 (1.38814)
a[21] = -1.10575e+01 (-11.0575)
a[22] = 8.85057e+01 (88.5057)
a[23] = -7.08002e+02 (-708.002)
a[24] = 5.66406e+03 (5664.06)
a[25] = -4.53124e+04 (-45312.4)
a[26] = 3.62499e+05 (362499)
For float (single precision variables):
a[ 0] = 0.117783
a[ 1] = 0.057736
a[ 2] = 0.038114
a[ 3] = 0.028421
a[ 4] = 0.022634
a[ 5] = 0.018929
a[ 6] = 0.015234
a[ 7] = 0.020985
a[ 8] = -0.042877
a[ 9] = 0.454128
a[10] = -3.533023
For double (double precision) variables:
a[ 0] = 0.117783
a[ 1] = 0.057736
a[ 2] = 0.038114
a[ 3] = 0.028419
a[ 4] = 0.022647
a[ 5] = 0.018821
a[ 6] = 0.016099
a[ 7] = 0.014064
a[ 8] = 0.012486
a[ 9] = 0.011225
a[10] = 0.010196
Try this link:
http://www.dartmouth.edu/~chance/teaching_aids/books_articles/probability_book/Chapter11.pdf
How do you run a recurrence in the backwards direction?
Take the rightmost 4 digits of each number, with all numbers having the same number of decimal digits (it looks like 6 here). Add them up. If there's overflow and the rightmost (least significant digit) isn't zero, round so you still only have 4 digits to worry about. Repeat until the entire set of numbers is added.
Here I'm only using 4 instead of (maybe) 5 digits, and I'm only shifting left 1 digit at a time when I could possibly shift more, but I think this conveys the idea.
Are you pointing out that the intermediate calculations may need more than 6 digits to store the result?
I presume took M =
5 5
1 0
By decomposing M = S D (S inverse), with D being the eigenvalues:
( 5+3root5)/2, (5-3root5)/2 )
with S containing the corresponding eigenvectors, you get:
M^n = S D^n (S inverse).
The entries of M^n are powers of the eigenvalues suitably
jumbled together by the eigenvectors. From there you get your sum.
The sum is in principle summable exactly since it is the differential
of a geometric series, but things are getting horribly messy by now.
Is there any easier way to do this?
Yes, I added the terms up in the "forward direction".
What is 'smearing', and is there a better way to do the sum (presumably backwards?)?
The 2 articles I found are:
http://www.dartmouth.edu/~chance/teaching_aids/books_articles/probability_bookChapter11.pdf
http://protist.biology.washington.edu/biol429/Lecture%20notes/Lecture8_Analyzing_Markov_Chains.pdf
The analytical approach is much easier. I've verified it works in another simpler problem. However I don't see the logic behind it yet. I have found some pdf's about it and am trying to digest them.
What do you mean by "run in the forward direction"?
Let's calculate the expected number of throws to get a 3,3 by counting the number
of sequences that win in exactly n throws. Clearly the last 2 throws are 3,3 and
that there are no 3,3 subsequences prior to that.
Call an n-seq a sequence of length n where the last 2 throws are 3,3.
For instance, some 6-seq are:
124533, 343533, 215533, 236533, but not
433133, 335633, 145333.
Clearly the number of:
2-seq=1 (33)
3-seq=5 (133,233,433,533,633)
<expected number> =
# throws=n * prob( n throws ), summed over n=1 to infinity.
= 2*(1/36) + 3*(5/216) + ...
We need to count the number of n-seq.
To create an n+1-seq from an n-seq, prepend a throw to the n-seq. If the first
throw of the n-sequence was a 3, there are 5 choices [1,2,4,5,6]. If the first
throw was not a 3, there are 6 choices - 5 of which are not 3 and 1 of which is a 3.
Call:
A(n) := n-seq whose 1st throw != 3.
B(n) := n-seq whose 1st throw = 3.
Then:
A(3)=5, B(3)=0, and the number of 3-seq = A+B = 5.
A(4)=25,B(4)=5, and the number of 4-seq = A+B = 30.
The recursion relation is:
A(n+1) = 5*A(n) + 5*B(n)
B(n+1) = A(n);
Programming a computer to actually add all these numbers together gives:
expected value = 41.972222, where I must be losing accuracy from rounding error.
A similar calculation for 3,4 with
A(n) := n-seq whose 1st throw != 4.
B(n) := n-seq whose 1st throw = 4.
A(n+1) = 5*A(n) + 4*B(n)
B(n+1) = A(n) + B(n)
A(3)=5, B(3)=1
gives:
expected value = 35.972222
The random number generator is from Borland's Turbo C.
The number of simulations is greater than 1 million.
To read the result of the simulation below, use "ave = tot / #".
sequence 33: #=1007117; tot=20197276.000000; ave=20.054548
sequence 34: #=1174266; tot=23728800.000000; ave=20.207346
It's beginning to make intuitive sense.
Suppose you play a game between 2 people, and the rules of the game are as follows:
1. Player A wins if he gets a sequence 1,2.
2. Player B wins if he gets a sequence 3,4.
The expected number of rolls to win for both A and B are the same. It's a fair game.
Now modify rule 1:
3. Player A wins if he gets a sequence 1,2. However, upon rolling the first 1, he has to flip a coin. If the coin lands heads, he continues as before. If the coin lands tails, he has to start all over again (effectively erasing the '1' he already has).
Clearly player A is playing under a handicap. His expected number of rolls increases. A game between A and B is now clearly unfair.
Thank you for showing your calculations.
I am getting the following results:
1. The game is: 1 person repeatedly throws 1 dice. He stops when he gets 3,3.
Result: The game takes on average 42 rolls. (weird!)
2. The game is: 1 person repeatedly throws 1 dice. He stops when he gets 3,4.
Result: The game takes on average 36 rolls.
3. The game is: 1 person repeatedly throws 1 dice. Each time he rolls he increments a "number of throws" counter. Each time gets a 3,3 he increments a "number of sequences" counter.
Result: After many throws, the average:
"number of sequences" / "number of throws" = 36.
4. The game is: 1 person repeatedly throws 1 dice. Each time he rolls he increments a "number of throws" counter. Each time gets a 3,4 he increments a "number of sequences" counter.
Result: After many throws, the average:
"number of sequences" / "number of throws" = 36.
5. The game is: 1 dice is repeatedly thrown. 2 people look at the same dice. Person A wins if a 3,3 comes up first. Person B wins if 3,4 comes up first.
Result: The game is fair. Person A and Person B win about equally often. Each game lasts about 21 throws.
Remember, a game stops if either sequence 3,3 or 3,4 show up.
6. The game is:
Person A throws person A's dice. Person A wins if a 3,3 comes up on person A's dice.
Person B throws person B's dice. Person B wins if a 3,4 comes up on person B's dice.
Each person throws, then they look at their dice at the same time.
Person A could win, Person B could win or they could both win.
Result: The game is not fair. Person B wins more often.
Person B wins about 7% more often.
The average number of games for person A to win is about 20.1.
The average number of games for person B to win is about 20.3
The results for games 1-5 seem ok.
That game 6 isn't fair and that person B wins more often also seems ok.
However I'm not sure why the average number of games is 20+ for scenario 6 vs. 21 for scenario 5.
If you have Mathematica code, please post it. I will try to read how your game is structured from the code.
If I'm not looking at the right game, please post a clear, concise description of the problem that you are describing. I will try to see how I've misinterpreted the problem.
I agree that the expected number of rolls to get one 3 by repeatedly tossing one dice is 6, not 3.5.
This shows up both in a simulation using code similar to the code I posted before, as well as summing the series:
s*1 + f*s*2 + f*f*s*3 + f*f*f*s*4 + ...
where s = 1/6 and f=5/6 (read success or failure), and the 1,2,3... are the number of tosses
(calculating the expected value of the number of tosses).
However we still disagree on the expected number of tosses for the sequences 33 and 34.
If you did a simulation, please post your simulation code.
If not, please post your derivation. There is no point in drawing this out further. I've already shown you my work, now please show me yours.
I looked at 109 and 148, but didn't see an explanation for this problem.
Yes, looking at the sequence 1,1 vs 1,2 should be the same thing.
I suppose that looking at the sequence Heads, Heads vs. Heads, Tails should also be the same for a coin flipping game.
If the problem is stated: "Let's toss a dice until 33 or 34 shows up. Then someone wins. Then we start all over again (from scratch). Keep going. Who wins more often, and what is the expected number of tosses before a win?", I don't see why one sequence is preferred over another.
Any number tossed other than 3 or 4 is noise and effectively restarts the game. Keep tossing a dice until a 3 shows up. The next toss determines if 33 wins, if 34 wins, or if the problem starts all over again. Since the next toss is equally likely to be 3 or 4, I don't see why the sequence 33 is preferred over 34 or vice versa.
Here is some C code for a simulation:
#include <conio.h>
#include <math.h>
#include <stdlib.h>
void main( void )
{
unsigned ctr,toss, sw, n33, n34;
float tot33, tot34;
float ave33, ave34;
clrscr();
tot33=0L;
tot34=0L;
n33=0;
n34=0;
l:
for(sw=0,ctr=0;(n34<30000) && !kbhit();)
{ toss = 1+6.*rand()/RAND_MAX; /* printf("%d\n",toss); */
ctr++;
if (0==sw)
{ sw = (3==toss) ? 1 : 0; }
else /* 1==sw */
{ switch(toss)
{ case 3: /*printf("33: %d\n",ctr);*/
n33++; tot33+=ctr;
ave33 = tot33/n33;
goto l;
case 4: /*printf("34: %d\n",ctr);*/
n34++; tot34+=ctr;
ave34 = tot34/n34;
goto l;
default: sw=0; break;
} }
}
printf("33: #=%u; tot=%f; ave=%f\n",n33,tot33,ave33);
printf("34: #=%u; tot=%f; ave=%f\n",n34,tot34,ave34);
}
The result of running this simulation until "34" has 30000 wins is:
33: #=30160; tot # tosses=633824.000000; ave # of tosses=21.015385
34: #=30000; tot # tosses=633490.000000; ave # of tosses=21.116333
Both a win with "33" and "34" are averaging 21 tosses. The 0.1 difference, and whether 33 or 34 is more, varies depending on how many games are run and the starting random number seed.
21 tosses seems reasonable because it's close to half of 36 + 2 (sequence length). For instance, the expected number of tosses needed to get one 3 by tossing one dice should be 3.5(?).
So I'm still wondering what the reasoning is behind the 36 and 42 numbers.
I do see that in the complete set of 3 tosses of a fair coin,
HHH
HHT
HTH
HTT
THH
THT
TTH
TTT
there are 4 sequences containing HT, and only 3 containing HH. However if this were a game with a notion of time, then HH wins in 3 sequences and HT wins in 3 sequences. What happened is that HHT contains an HT sequence, but HH had already won this game on the 2nd move.
I'd like to see the reasoning behind 1/36 and 1/42. Can you please post it?
Pages: 1