Emulator Coder, Skilled player (1113)
Joined: 5/1/2010
Posts: 1217
Warp wrote:
1) Since pi is an irrational number, and moreover a transcendental number, then its decimal expansion is pretty much "random", so in principle any finite series of digits ought to appear somewhere in it.
There are transcendental numbers that do not even have some digit appearing at all. There exists decimal (base-10) transcendental number consisting entirely of zeros and ones. There also are transcendental numbers that have all the base-10 digits in decimal, but don't even have all 100 pairs of consecutive digits appear. It is not known if different digits in decimal expansion of pi all have probability of 10%, or not.
Patashu
He/Him
Joined: 10/2/2005
Posts: 4044
A similar question is 'Is pi a Normal number ?' Here is an interesting quote: "Determining if numbers are normal is an unresolved problem. It is not even known if fundamental mathematical constants such as pi (Wagon 1985, Bailey and Crandall 2003), the natural logarithm of 2 ln2 (Bailey and Crandall 2003), Apéry's constant zeta(3) (Bailey and Crandall 2003), Pythagoras's constant sqrt(2) (Bailey and Crandall 2003), and e are normal, although the first 30 million digits of pi are very uniformly distributed (Bailey 1988)." Though one could imagine a non-normal number that does have every possible series of digits within it. For example, concatenating the digits of every number one after the other, and doing it twice if it contains only 1s, is a non-normal number containing every possible series of digits. However, I would expect every 'non-constructed, transcendental' normal number to also contain all subsequences in it.
My Chiptune music, made in Famitracker: http://soundcloud.com/patashu My twitch. I stream mostly shmups & rhythm games http://twitch.tv/patashu My youtube, again shmups and rhythm games and misc stuff: http://youtube.com/user/patashu
Joined: 12/10/2006
Posts: 118
Why are a million zeros hard to imagine? Are 5, 10 or 50 too?
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
What is the largest string of the same digit found in the decimal expansion of pi so far?
Player (80)
Joined: 8/5/2007
Posts: 865
Patashu wrote:
For example, concatenating the digits of every number one after the other
This is known as the Champernowne constant. It is one of the few numbers known to be normal (it's practically defined to be so). It is also, in a sense, extremely unrandom (although even that is debatable).
Patashu wrote:
and doing it twice if it contains only 1s
I'm confused about this condition. What does it mean, and does it serve some purpose? Is there some exception that needs to be taken into account? * * * If you're bored, use a program that can perform long division to arbitrary precision (200+ digits; I recommend Mathematica, although I also wrote a Matlab program to do the same. Or just use this website.) and enter the following: 60499999499/490050000000 What is the result? Why can it be expressed so accurately in such a short and alluringly elegant rational quotient? (Honestly, I don't entirely know, but I studied it enough to get a few hints.)
Player (36)
Joined: 9/11/2004
Posts: 2630
Warp wrote:
What is the largest string of the same digit found in the decimal expansion of pi so far?
http://www.numberworld.org/ this guy could find out for you. But I don't think anyone actually knows right now.
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Patashu
He/Him
Joined: 10/2/2005
Posts: 4044
Bobo the King wrote:
Patashu wrote:
and doing it twice if it contains only 1s
I'm confused about this condition. What does it mean, and does it serve some purpose? Is there some exception that needs to be taken into account?
The purpose is to create a number containing every string but not being normal (it is biased towards having more 1s than other numbers).
My Chiptune music, made in Famitracker: http://soundcloud.com/patashu My twitch. I stream mostly shmups & rhythm games http://twitch.tv/patashu My youtube, again shmups and rhythm games and misc stuff: http://youtube.com/user/patashu
Tub
Joined: 6/25/2005
Posts: 1377
Patashu wrote:
A similar question is 'Is pi a Normal number ?'
To get back to Warp's original question: if Pi is indeed a Normal Number (which is yet unproven), then yes, it will contain every finite sequence you can think of. Granted, for any sequence of a million digits, the chance for them to be all zeros is 1 / ( 10 ^ 1.000.000 ), a very very small number. For example, if you were to pick a random spot (of planck length) in the observable universe, at a random moment (of planck time) since the big bang, then your chance of picking exactly the time and place of the first neuron firing inside baby Einstein's brain[1] is merely around 1 / ( 10 ^ 250). So if you pick a truly random sequence of a million digits, it's very likely that there has never been, and will never be, a physical representation of said sequence in our universe.[2] But Pi is different. Its decimal expansion is infinite. So we need to take a look at an estimated 10 ^ 1.000.000 subsequences of Pi until we find one that matches? How many subsequences are there in Pi? Infinitely many, which is not only enough to find one match with probability 1, but an infinite amount of matches. [1] or baby hitler's brain, if you prefer. Or any other point in our spacetime. [2] well, unless you pick a sequence by writing it down or storing it in your computer's memory. Sampling bias, hu?
m00
arflech
He/Him
Joined: 5/3/2008
Posts: 1120
A few hours ago, TASeditor uploaded the following video demonstrating an example of a linear-feedback shift register (LFSR): https://en.wikipedia.org/wiki/Linear_feedback_shift_register Link to video As the Wikipedia article shows for the 4-bit (nibble) case of this register (which actually can make sense for as few as two bits), the two cycles are the fixed point (0000:0) and a cycle of length 15 containing all of the other nibbles; after watching that video, I decided to figure out what the cycles were for the 8-bit (byte) case. I went ahead and did it manually and the results are below:
Language: txt

Cycle 0 (Length 1) 00000000:00:0 Cycle 1 (Length 63) 00000001:01:1 10000000:80:128 01000000:40:64 00100000:20:32 00010000:10:16 00001000:08:8 00000100:04:4 00000010:02:2 10000001:81:129 11000000:C0:192 01100000:60:96 00110000:30:48 00011000:18:24 00001100:0C:12 00000110:06:6 10000011:83:131 01000001:41:65 10100000:A0:160 01010000:50:80 00101000:28:40 00010100:14:20 00001010:0A:10 10000101:85:133 11000010:C2:194 11100001:E1:225 11110000:F0:240 01111000:78:120 00111100:3C:60 00011110:1E:30 10001111:8F:143 01000111:47:71 00100011:23:35 00010001:11:17 10001000:88:136 01000100:44:68 00100010:22:34 10010001:91:145 11001000:C8:200 01100100:64:100 00110010:32:50 10011001:99:153 11001100:CC:204 01100110:66:102 10110011:B3:179 01011001:59:89 10101100:AC:172 01010110:56:86 10101011:AB:171 01010101:55:85 10101010:AA:170 11010101:D5:213 11101010:EA:234 11110101:F5:245 11111010:FA:250 11111101:FD:253 11111110:FE:254 11111111:FF:255 01111111:7F:127 00111111:3F:63 00011111:1F:31 00001111:0F:15 00000111:07:7 00000011:03:3 Cycle 5 (Length 63) 00000101:05:5 10000010:82:130 11000001:C1:193 11100000:E0:224 01110000:70:112 00111000:38:56 00011100:1C:28 00001110:07:14 10000111:87:135 01000011:43:67 00100001:21:33 10010000:90:144 01001000:48:72 00100100:24:36 00010010:12:18 10001001:89:137 11000100:C4:196 01100010:62:98 10110001:B1:177 11011000:D8:216 01101100:6C:108 00110110:36:54 10011011:9B:155 01001101:4D:77 10100110:A6:166 11010011:D3:211 01101001:69:105 10110100:B4:180 01011010:5A:90 10101101:AD:173 11010110:D6:214 11101011:EB:235 01110101:75:117 10111010:BA:186 11011101:DD:221 11101110:EE:238 11110111:F7:247 01111011:7B:123 00111101:3D:61 10011110:9E:158 11001111:CF:207 01100111:67:103 00110011:33:51 00011001:19:25 10001100:8C:140 01000110:46:70 10100011:A3:163 01010001:51:81 10101000:A8:168 01010100:54:84 00101010:2A:42 10010101:95:149 11001010:CA:202 11100101:E5:229 11110010:F2:242 11111001:F9:249 11111100:FC:252 01111110:7E:126 10111111:BF:191 01011111:5F:95 00101111:2F:47 00010111:17:23 00001011:0B:11 Cycle 9 00001001:09:9 10000100:84:132 01000010:42:66 10100001:A1:161 11010000:D0:208 01101000:68:104 00110100:34:52 00011010:1A:26 10001101:8D:141 11000110:C6:198 11100011:E3:227 01110001:71:113 10111000:B8:184 01011100:5C:92 00101110:2E:46 10010111:97:151 01001011:4B:75 00100101:25:37 10010010:92:146 11001001:C9:201 11100100:E4:228 01110010:72:114 10111001:B9:185 11011100:DC:220 01101110:6E:110 10110111:B7:183 01011011:5B:91 00101101:2D:45 10010110:96:150 11001011:CB:203 01100101:65:101 10110010:B2:178 11011001:D9:217 11101100:EC:236 01110110:76:118 10111011:BB:187 01011101:5D:93 10101110:AE:174 11010111:D7:215 01101011:6B:107 00110101:35:53 10011010:9A:154 11001101:CD:205 11100110:E6:230 11110011:F3:243 01111001:79:121 10111100:BC:188 01011110:5E:94 10101111:AF:175 01010111:57:87 00101011:2B:43 00010101:15:21 10001010:8A:138 11000101:C5:197 11100010:E2:226 11110001:F1:241 11111000:F8:248 01111100:7C:124 00111110:3E:62 10011111:9F:159 01001111:4F:79 00100111:27:39 00010011:13:19 Cycle 13 (Length 63) 00001101:0D:13 10000110:86:134 11000011:C3:195 01100001:61:97 10110000:B0:176 01011000:58:88 00101100:2C:44 00010110:16:22 10001011:8B:139 01000101:45:69 10100010:A2:162 11010001:D1:209 11101000:E8:232 01110100:74:116 00111010:3A:58 10011101:9D:157 11001110:CE:206 11100111:E7:231 01110011:73:115 00111001:39:57 10011100:9C:156 01001110:4E:78 10100111:A7:167 01010011:53:83 00101001:29:41 10010100:94:148 01001010:4A:74 10100101:A5:165 11010010:D2:210 11101001:E9:233 11110100:F4:244 01111010:7A:122 10111101:BD:189 11011110:DE:222 11101111:EF:239 01110111:77:119 00111011:3B:59 00011101:1D:29 10001110:8E:142 11000111:C7:199 01100011:63:99 00110001:31:49 10011000:98:152 01001100:4C:76 00100110:26:38 10010011:93:147 01001001:49:73 10100100:A4:164 01010010:52:82 10101001:A9:169 11010100:D4:212 01101010:6A:106 10110101:B5:181 11011010:DA:218 11101101:ED:237 11110110:F6:246 11111011:FB:251 01111101:7D:125 10111110:BE:190 11011111:DF:223 01101111:6F:111 00110111:37:55 00011011:1B:27 Cycle 109 (Length 3) 01101101:6D:109 10110110:B6:182 11011011:DB:219
The six cycles are indexed by the smallest possible seeds, although it might not be the most illuminating way to look at the bit-patterns; I've also considered coloring a 16x16 grid to show how these five cycles are related, possibly to see what special properties the members of the last cycle (109, 182, and 219) share. Here are the cycles for some cases below 8 bits... 2-bit: 00:0, 01:1 - 10:2 - 11:3 3-bit: 000:0, 001:1 - 100:4 - 010:2 - 101:5 - 110:6 - 111:7 - 011:3 4-bit: 0000:0:0, 0001:1:1 - 1000:8:8 - 0100:4:4 - 0010:2:2 - 1001:9:9 - 1100:C:12 - 0110:6:6 - 1011:B:11 - 0101:5:5 - 1010:A:10 - 1101:D:13 - 1110:E:14 - 1111:F:15 - 0111:7:7 - 0011:3:3 5-bit...
Language: txt

Cycle 0 (Length 1) 00000:00:0 Cycle 1 (Length 21) 00001:01:1 10000:10:16 01000:08:8 00100:04:4 00010:02:2 10001:11:17 11000:18:24 01100:0C:12 00110:06:6 10011:13:19 01001:09:9 10100:14:20 01010:0A:10 10101:15:21 11010:1A:26 11101:1D:29 11110:1E:30 11111:1F:31 01111:0F:15 00111:07:7 00011:03:3 Cycle 5 (Length 7) 00101:05:5 10010:12:18 11001:19:25 11100:1C:28 01110:0E:14 10111:17:23 01011:0B:11 Cycle 13 (Length 3) 01101:0D:13 10110:16:22 11011:1B:27
In the first three cases, the partitioning into cycles is trivial: "Cycle 0" of length 1, and "Cycle 1" of length 2n-1-1 for n-bit words. It turns out the 6- and 7-bit cases also follow this pattern, but I won't type them all out here. The challenge is to describe the set of cycles of this LFSR as the number of bits increases; based on reading that Wikipedia article, I suspect it has to do with the factorization of xn+xn-1+1, and I've seen from Wolfram Alpha that this polynomial is reducible over the Reals (and therefore over GF(2)) when n is 5, 8, 11, or 14, and additionally is reducible over GF(2) (but not the Reals) when n is 10, 12, 13 or 16. As a side-note, this means that the LFSR demonstrated in the video is a poor one for retro games; the ideal case would have the trivial cycle and a cycle of length 25, based on the polynomial x8+x6+x5+x4+1 (that is, by using XOR on the least significant bit, the third least significant, and the two to the left of that).
i imgur com/QiCaaH8 png
Post subject: Normal Number
Buddybenj
He/Him
Joined: 1/12/2013
Posts: 166
Location: USA
I'm surprised this thread has been going as long as it has. Also Pi being a normal number would be interesting... If I recall Numberphile had a video on it a while back.
Projects: Interested in TASing N64 Mario Golf. GBA Mario Tennis: Power Tour is on hold.
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
I started thinking: A 4x4x4 rubik's cube can be used to "emulate" both a 2x2x2 cube and a 3x3x3 cube. (If, from the solved state, you only rotate halves of the cube, it will effectively work as a 2x2x2, and if you only rotate the outer slices, it will effectively work as a 3x3x3.) On the other hand, a 3x3x3 cannot be used to emulate a 2x2x2 (unless you completely ignore the center slices, ie. don't care that they may end up scrambled, and only care about the corner pieces, but I'm not counting that as valid). Also, you can use a 5x5x5 to emulate a 3x3x3 but not a 4x4x4 nor a 2x2x2. This got me thinking: What's the general formula for which smaller-sized cubes can be emulated using an nxnxn-sized cube? At first one would think that this might have something to do with divisors, but it's not that simple. One of the major and most obvious reasons for this is that any cube larger than 3x3x3 can be used to emulate a 3x3x3 (when you rotate only the outer slices.) Thus the answer is not that trivial.
Skilled player (1652)
Joined: 7/25/2007
Posts: 299
Location: UK
So we have a cube with N columns, trying to simulate one with n columns. For N=4, we use grouping G={2,2} to simulate n=2, and G={1,2,1} to simulate n=3, with obviously G={1,1,1,1} being the default N=n=4; Where |G|=n. Clearly this is just ways to split up our integer N into different sized sets, subject to certain conditions we hope to derive along the way. For example, we cannot use 4={1,1,2} as an emulator for n=3, because on the left side we have a face by itself, but we on the right we have the face paired off with an edge section. This means that when solving it, it'll eventually be split up. EG the two (Face, Direction) rotations: (Bottom, Left), (Left Up) would separate part of the 2x2 simulated cube initially in the bottom right corner. This is because of the lack of symmetry in the {1,1,2} expression. IE if we have tiles 'a' and 'b' in the 3rd emulated set (--,--,ab), after a rotation we have (a,b,--), which will then be separated upon moving either column. So we need each tile to be paired with just as many pieces on one side as the other, thus our given emulator distribution MUST be symmetrical. For all N>3, we we have N={1,(n-2),1}, which is of course symmetrical and has magnitude 3, thus an n=3 cube can always be emulated for any N. For N=5, we also have G={1,3,1}={2,1,2} for n=3 emulation. We cannot have n=2, because we have 5 columns to pair off to our 2 emulated sides. Since we cannot split this evenly, it is not possible. Now in terms of symmetry, it depends on if we have an odd or even number of columns, thus if we have a central column or not. IE for n odd, we need its central column to be emulated, done differently depending on if N is odd or even. If N is even, we can do this by having equal amounts of columns adjacent to the central divide as being treated as a single block. EG {1,2,1} gives us an emulated central column, so n=3 can be done inside N=4. Note here that the size of that central column (2) is even, but if we have N odd, then the central column in N does not get split up, but instead needs to be bunched with equal amounts of columns on both sides, thus we would have the size of the middle string being odd. EG for n=3 inside N=5, gives G={1,3,1}={2,1,2}, where both middle columns have odd numbers. Hence we have a solution for N odd. Either way, n odd can be emulated in both N even and N odd. But for n even, we need to split the columns of N into an even amount, one which is clearly impossible if N is odd, thus N also needs to be even. Thus N odd can emulate only n odd, N even can emulate n both odd or even. This is true for All N>n, for example: N=4. {1,1,1,1}, {1,2,1}, {2,2}. N=5. {1,1,1,1,1}, {1,3,1}={2,1,2}. N=6. {1,1,1,1,1,1}, {1,1,2,1,1}, {1,2,2,1}={2,1,1,2}, {1,4,1}={2,2,2}. {3,3}. N=7. {1,1,1,1,1,1,1}, {1,1,3,1,1}, {1,5,1}={2,3,2}={3,1,3}. N=8. {1,1,1,1,1,1,1,1}, {1,1,1,2,1,1,1}, {1,1,2,2,1,1}={1,2,1,1,2,1}={2,1,1,1,1,2}, {1,1,4,1,1}={1,2,2,2,1}={2,1,2,1,2}, {1,3,3,1}={3,1,1,3}={2,2,2,2}, {1,6,1}={2,4,2}={3,2,3}, {4,4}. So Odd cubes can only emulate smaller odd cubes. Even cubes can emulate all smaller cubes. Basically because the emulation will take the symmetric form of either G={---k---,---k'---} or G={--k--,m,--k'--}; thus giving total group size=emulator size of the form a+a=2a=even, or a+b+a=2a+b which can be made even or odd.
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
Flip wrote:
So Odd cubes can only emulate smaller odd cubes. Even cubes can emulate all smaller cubes.
That was an interesting analysis and result. While it seems clear in hindsight, it was not trivial to see at first. Thanks.
Editor, Expert player (2078)
Joined: 6/15/2005
Posts: 3282
arflech wrote:
The challenge is to describe the set of cycles of this LFSR as the number of bits increases; based on reading that Wikipedia article, I suspect it has to do with the factorization of xn+xn-1+1, and I've seen from Wolfram Alpha that this polynomial is reducible over the Reals (and therefore over GF(2)) when n is 5, 8, 11, or 14, and additionally is reducible over GF(2) (but not the Reals) when n is 10, 12, 13 or 16.
It has to do partially with the factorization of xn+xn-1+1 (mod 2) (or equivalently, factorization of the reverse xn+x+1 (mod 2)), but it is more complex than just factorization. I can't explain everything in complete detail, but this is how it goes (everything below is in mod 2 land): - Every LFSR is equivalent to a Galois LFSR. Example for x16+x14+x13+x11+1 (credit Wikipedia): - The internal state of the Galois LFSR above (lower image) can be represented by the polynomial given by sum(ith bit is 1) xi, where the leftmost bit is bit 0 and bit position counts left to right. Example above: 1+x2+x4+x5+x8+x9+x10+x15. - Cycling the Galois LFSR is as simple as multiplying the polynomial internal state by x and taking the remainder upon division by the reverse of the LFSR's polynomial 1+x2+x3+x5+x16. - Let f(x) be the reverse of the LFSR's polynomial and p(x) be the initial Galois LFSR state. Then the question is: what is the smallest positive n such that f(x) divides p(x)(xn-1)? - Factor f(x) into irreducible factors f1(x)f2(x)...fk(x). Then for each irreducible factor that does not divide p(x), the question is: what is the smallest positive ni such that fi(x) divides xni-1?. If f(x) itself is irreducible, then it cannot divide p(x) (since deg f > deg p) unless p(x) is the zero polynomial. - Even if f(x) is irreducible, that doesn't necessarily mean that the LFSR has period 2deg f-1 (the maximum) for nonzero initial values. In order for that to happen, the smallest positive n for which f(x) divides xn-1 must be 2deg f-1. In this case, f(x) is a primitive polynomial (field theory definition of primitive, not gcd definition). - Note that every polynomial with nonzero constant term is a divisor of xn-1 for some n. In particular, an irreducible polynomial g(x), other than x, is a divisor of x^(2deg g-1)-1. This follows from field theory but I won't go into it here. At this point, it is easier just to do small examples. The polynomials of interest are the reversals of xn+xn-1+1, that is, xn+x+1. n=5: x5+x+1=(x2+x+1)(x3+x2+1). Note that both x2+x+1 and x3+x2+1 are primitive polynomials. Let p(x) be the polynomial for the initial Galois LFSR state. Let g(p(x))=(u(x),v(x)) where u(x) is remainder of p(x) divided by x2+x+1 and v(x) is remainder of p(x) divided by x3+x2+1 (this is unique by the Chinese Remainder Theorem). If g(p(x))=(0,0) (p(x) is the zero polynomial), then the cycle has length 1. If g(p(x))=(u(x),0) for nonzero u(x), then the cycle has length 22-1=3 (since x3+x2+1 divides p(x), its only contribution is from x2+x+1) If g(p(x))=(0,v(x)) for nonzero v(x), then the cycle has length 23-1=7. If g(p(x))=(u(x),v(x)) for nonzero u(x) and v(x), then the cycle has length gcd(3,7)=21; this covers all possible values as well. n=8: x8+x+1=(x2+x+1)(x6+x5+x3+x2+1). Note that both x2+x+1 and x6+x5+x3+x2+1 are primitive polynomials. Let p(x) be the polynomial for the initial Galois LFSR state. Let g(p(x))=(u(x),v(x)) where u(x) is remainder of p(x) divided by x2+x+1 and v(x) is remainder of p(x) divided by x6+x5+x3+x2+1. If g(p(x))=(0,0) (p(x) is the zero polynomial), then the cycle has length 1. If g(p(x))=(u(x),0) for nonzero u(x), then the cycle has length 22-1=3. If g(p(x))=(0,v(x)) for nonzero v(x), then the cycle has length 26-1=63. If g(p(x))=(u(x),v(x)) for nonzero u(x) and v(x), then the cycle has length gcd(3,63)=63. For a given v(x), there are 3 possible values for u(x) in order to cover all possible values; thus, this gives 3 classes of length 63, for a total of 4. n=9: x9+x+1 is irreducible. Now since the smallest positive n such that x9+x+1 divides xn-1 is n=73 (instead of n=29-1=511), x9+x+1 is not primitive. In fact, if p(x) is the initial Galois LFSR state, and p(x) is not the zero polynomial, then the cycle has length 73. There are 7 such cycles. Of course, if p(x)=0, then the cycle has length 1. Now, it's pretty hard to characterize the factorizations of xn+x+1, even if polynomial factorization can be done quickly (faster than integer factorization for sure). The only other thing I can say is that x2+x+1 is always a divisor of xn+x+1 when n=2 (mod 3), and xn+x+1 is always square-free, since the gcd of xn+x+1 and its derivative is always 1. That's about it. Here are full factorizations of xn+x+1 (mod 2) from n=2 to 20. The symbol * after a factor means that it is not a primitive polynomial; in this case the smallest m for which it divides xm-1 is given. x2+x+1 x3+x+1 x4+x+1 x5+x+1=(x2+x+1)(x3+x2+1) x6+x+1 x7+x+1 x8+x+1=(x2+x+1)(x6+x5+x3+x2+1) x9+x+1* x10+x+1=(x3+x+1)(x7+x5+x4+x3+1) x11+x+1=(x2+x+1)(x9+x8+x6+x5+x3+x2+1) x12+x+1=(x3+x2+1)(x4+x3+1)(x5+x3+x2+x+1) x13+x+1=(x5+x4+x3+x+1)(x8+x7+x5+x3+1) x14+x+1=(x2+x+1)(x5+x3+1)(x7+x6+x5+x2+1) x15+x+1 x16+x+1=(x8+x6+x5+x3+1)(x8+x6+x5+x4+x3+x+1)* x17+x+1=(x2+x+1)(x3+x+1)(x12+x11+x10+x9+x8+x6+x4+x+1)* x18+x+1=(x5+x2+1)(x13+x10+x8+x7+x4+x3+x2+x+1) x19+x+1=(x3+x2+1)(x4+x+1)(x5+x4+x2+x+1)(x7+x5+x4+x3+x2+x+1) x20+x+1=(x2+x+1)(x5+x4+x3+x2+1)(x13+x11+x10+x9+x7+x4+1) x9+x+1: 73 x8+x6+x5+x4+x3+x+1: 85 x12+x11+x10+x9+x8+x6+x4+x+1: 273
Warepire
He/Him
Editor
Joined: 3/2/2010
Posts: 2178
Location: A little to the left of nowhere (Sweden)
I ran into this problem recently, I'm not sure it actually has an answer as I cannot find one, but perhaps my math simply isn't strong enough. Given a sequence of 19 pre-defined numbers, for simplicity sake, lets say 1-19. Is there a sensible way (like an algorithm) to get all possible re-ordered sequences of the given numbers?
Emulator Coder, Skilled player (1113)
Joined: 5/1/2010
Posts: 1217
Warepire wrote:
I ran into this problem recently, I'm not sure it actually has an answer as I cannot find one, but perhaps my math simply isn't strong enough. Given a sequence of 19 pre-defined numbers, for simplicity sake, lets say 1-19. Is there a sensible way (like an algorithm) to get all possible re-ordered sequences of the given numbers?
In C++, that can be done using std::next_permutation() (which cycles between possible re-orderings). Here is one implementation: http://stackoverflow.com/questions/17212596/stdnext-permutation-implementation-explanation-seeming-little-inefficient Be careful, there are about 10^17 such orderings.
Warepire
He/Him
Editor
Joined: 3/2/2010
Posts: 2178
Location: A little to the left of nowhere (Sweden)
Ilari wrote:
Warepire wrote:
I ran into this problem recently, I'm not sure it actually has an answer as I cannot find one, but perhaps my math simply isn't strong enough. Given a sequence of 19 pre-defined numbers, for simplicity sake, lets say 1-19. Is there a sensible way (like an algorithm) to get all possible re-ordered sequences of the given numbers?
In C++, that can be done using std::next_permutation() (which cycles between possible re-orderings). Here is one implementation: http://stackoverflow.com/questions/17212596/stdnext-permutation-implementation-explanation-seeming-little-inefficient Be careful, there are about 10^17 such orderings.
That was what I came up with too, I thought that there could have been a chance that I overlooked a better method. Seems not, thanks!
Player (80)
Joined: 8/5/2007
Posts: 865
Warepire wrote:
I ran into this problem recently, I'm not sure it actually has an answer as I cannot find one, but perhaps my math simply isn't strong enough. Given a sequence of 19 pre-defined numbers, for simplicity sake, lets say 1-19. Is there a sensible way (like an algorithm) to get all possible re-ordered sequences of the given numbers?
I know this was already answered, but it's an interesting problem that happens to be simple enough for me to tackle (very rare in this math challenges thread). I also don't know C++ that well, so I'd like to offer my own solution, even though it may match what is in Ilari's link. Let's work with a smaller set of numbers, just 6 through 10 (I'm using 6 through 10 instead of 1 through 5 because I'd like to use those integers later). First, sort them so our first permutation is 6, 7, 8 , 9, 10. Now, produce five bins whose minimal values are
1, 1, 1, 1, 1
and whose maximal values are
5, 4, 3, 2, 1
The bin values of 1, 1, 1, 1, 1 correspond to the first permutation, 6, 7, 8, 9, 10. To produce the next permutation, increment the leftmost bin until it "carries over" and increments the bin to its immediate right. So to produce the first eleven bin values, we would take...
1, 1, 1, 1, 1
2, 1, 1, 1, 1
3, 1, 1, 1, 1
4, 1, 1, 1, 1
5, 1, 1, 1, 1
1, 2, 1, 1, 1
2, 2, 1, 1, 1
3, 2, 1, 1, 1
4, 2, 1, 1, 1
5, 2, 1, 1, 1
1, 3, 1, 1, 1
And so on. How do we obtain a permutation from the bins? If n is the number in the bin, simply take the nth entry in our first permutation that remains in the list. After it has been added, remove it from the list. (Note this means our first permutation didn't have to be in order, we just need to preserve the list's ordering as we progress.) As an example, suppose our bins contain the values 4, 2, 2, 1, 1. The algorithm would look like this (written lazily in Lua-esque pseudocode):
List = {6, 7, 8, 9, 10}  --This is the original list.
Bins = {4, 2, 2, 1, 1}
Permutation = {}  --The final output is just the empty set so far.

--The first element in Bins is 4, so take the 4th element of List and insert it in Permutation:
Permutation = {9}

--Remove the fourth element of List because we can't use 9 in our permutation anymore:
List = {6, 7, 8, 10}

--(This could be done with Lua's table.remove function or some other programming equivalent.  Also note that algorithmically, it may be helpful to remove the first element of Bins so this entire process is done using table.remove and table.add.)

--Now repeat the process.  The second element of Bins is 2, so insert the second element of List into Permutation:
Permutation = {9, 7}

Don't forget to remove 7 from List:
List = {6, 8, 10}

Finishing the last three steps:
Permutation = {9, 7, 8}
List = {6, 10}
Permutation = {9, 7, 8, 6}
List = {10}
Permutation = {9, 7, 8, 6, 10}
And we're done! Because there are 5! different possible values of the Bins variable and each one corresponds to a unique permutation (this is easy to show), all permutations are accounted for. To produce the next permutation, just follow the process I outlined above, incrementing the leftmost bin until it "carries over" to the one to its immediate right and resets to 1. Well, after typing all of that out, I've suddenly realized that it does not produce unique permutations if some of the elements are identical. My recollection is that the combinatorics gets pretty difficult once identical elements are included, so I'll give the problem a little more thought and see if I can tweak the algorithm to suit it. Perhaps this is taken into account in the C++ algorithm? If not, then I propose that problem as the next math challenge.
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
So, Monty Hall once again... is as unintuitive as ever. So, you are playing a round of Monty Hall. You choose door number 1. The host opens one of the other doors and reveals a goat and gives you the chance to switch your selection. Would it be advantageous for you to switch? Since you are savvy and know the probabilities, you of course switch, in order to get the 2/3 win probability. However, if before your decision I told you that the host actually opened a door at random, without knowing what would be behind it (and it just happened to have the goat behind it in this particular case), would it still be advantageous to switch? "Of course", you say. "What goes inside the host's head doesn't change anything. The two other doors still have a 2/3 chance, and now I have information about which door it can't be. So of course it's advantageous to switch." Seems completely reasonable. If in a particular round the host reveals a goat door, we are within the standard Monty Hall scenario. The reason why that particular door was revealed shouldn't change anything. It's not like the probabilities change depending on what the host was thinking at that moment, or what he knew. This isn't (a pseudoscientific version of) quantum mechanics, after all; this is pure math. So let's test that scenario with a small computer program. Just to see that it works correctly we first implement the traditional scenario (the host always reveals a goat door, and the contestant always switches). This gives the expected 66% winning rate. Now we change the program so that the host opens a random door from the two unchosen doors, we discard the rounds where the car door was opened (because we are not interested in those rounds, we are only interested in the rounds where a goat door was opened at random, because our scenario was to see if it's advantageous to switch if you happen to be in a round where a goat door was opened) and then print the result. And our collective jaws drop to the floor when the program prints a winning rate of "50%" (or something close to it.) We review the program to see where the bug is, and can't find it. It still prints "50%" no matter how many times we run it. I wrote a small such program that runs a million rounds. With the classic Monty Hall scenario it prints 1000000 rounds, 667169 wins, 66% With the random-reveal version it prints 666267 rounds, 333630 wins, 50% Why does this happen? Why does the host knowing or not knowing affect the probabilities of those rounds where the goat was revealed? Why is this so unintuitive?
Joined: 5/13/2006
Posts: 283
I'm not sure, but it may not be fair to exclude a third of the results. When you include the 333733 rounds in which the host unwittingly revealed the car, you have a win rate of 33%, the same as only choosing once.
<Zurreco> if so called professional players cant adapt to every playing field, theyre obviously not that great
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
Including the rounds where the car door is revealed is not relevant to the problem I posed. The point was this: "if before your decision (to switch) I told you that the host actually opened a door at random, would it still be advantageous to switch?" All logic and intuition would dictate that it makes absolutely no difference what the host knew or didn't know in his head when he revealed the goat. Heck, you (as the contestant) cannot even know if this was a random or a deliberate reveal if I didn't tell you. Yet somehow it does make a difference...
Active player (500)
Joined: 11/19/2007
Posts: 128
I think the difference comes from the fact that the host revealing a goat is no longer a necessity, so when a goat IS revealed that gives us extra information about the possibilities of the game, changing the probabilities. It's clear that if the host revealed the car then we would instantly know we had lost, but we didn't know that before he had opened a door. In the original game, no information is conveyed like this because a goat is always revealed.
Skilled player (1652)
Joined: 7/25/2007
Posts: 299
Location: UK
Let's say there's Goat A, Goat B, and Car, so can use 'ABC' notation conveniently enough. Let the first letter be your choice, the second the revealed door, and thus the third letter what you could choose to switch to. Obviously the basic combinations are: ABC ACB BAC BCA CAB CBA The problems stem from conditional probability, trying to keep track of which remaining possibilities/combinations we're actually talking about here. There's 1/3 chance of picking A first say, and thus 2 remaining doors to play with. However, this is where the two games diverge, since normally the host never shows you the car. This means that given A, there's a 0% chance of him doing 'ACB', and thus 100% chance of it being 'ABC'. If we choose C first, then he can show us either A or B, with probability of 50% each, thus: ABC=1/3*1=1/3 ACB=1/3*0=0 BAC=1/3*1=1/3 BCA=1/3*0=0 CAB=1/3*1/2=1/6 CBA=1/3*1/2=1/6 Good: ABC+BAC=1/3+1/3=2/3 Bad: CAB+CBA=1/6+1/6=1/3 Those give the standard figures. For your alternative game, we no longer deliberately discard 'ACB' and 'BCA' from the start, because he could accidentally show you the car now. This means that given A as your first choice, it's no longer 100% that he'll show you B next, but he may also show C, with probability 50% each. This changes it from the standard 100/0 split the game had before, to 50/50. This means the probabilities of each set occurring are no longer biased against one particular set, giving us a normal distribution of ABC=1/3*1/2=1/6 ACB=1/3*1/2=1/6 -Discarded after BAC=1/3*1/2=1/6 BCA=1/3*1/2=1/6 -Discarded after CAB=1/3*1/2=1/6 CBA=1/3*1/2=1/6 Good: ABC+BAC=1/6+1/6=2/6=1/3 Bad: CAB+CBA=1/6+1/6=2/6=1/3 Here we have P(Good)=P(Bad)=1/3, with the remaining 1/3 being discarded, IE restarting the game. So given that we actually had a successful game, we have equal chances of switching being a good or bad thing, thus the 50% figure you got. Why is that counter intuitive? Well instead of the host choosing to get rid of a bad prize, he just gets rid of a prize at random, then of course that's gonna lower your chance of winning isn't it? Would've thought that's expected.
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
That explains why the simulation gives 66% in one situation and 50% in the other. The question remains, though: If you are playing one single round, and the host reveals a goat door, is it advantageous to change? Let's say you don't know if the host opened the door randomly or knowingly. How would you even know, if nobody tells you? How do you know if you are in the standard Monty Hall setup, or in the randomized version? There's no way of knowing. More puzzlingly, even if you do know, why would that make any difference? If you were playing several rounds, then it obviously makes a difference. In the randomized variation you are, effectively, playing with two doors, which is why there's a 50/50 chance. In the normal version no door is discarded, so you have the 66/33 chance. I think this puts the original question in a new light, given that the original Monty Hall problem (at least implicitly) talks about one single round. Does it really make a difference whether you switch or not?
Editor, Expert player (2078)
Joined: 6/15/2005
Posts: 3282
Warp wrote:
If you are playing one single round, and the host reveals a goat door, is it advantageous to change? Let's say you don't know if the host opened the door randomly or knowingly. How would you even know, if nobody tells you? How do you know if you are in the standard Monty Hall setup, or in the randomized version? There's no way of knowing.
Let's also assume that the host is allowed to use any strategy whatsoever, not just the two strategies mentioned (random, and Monty Hall/always open goat door) and the player has no way of knowing. This becomes a game-theoretic question. The player can never do worse than 50%. Flip a coin. Don't switch if heads, switch if tails. No matter what strategy the host does, given that the opened door is a goat, switching is either right or wrong. Assigning 50% probabilities to switch or not switch gives 50% success rate, no matter what. On the other hand, the host can set it up so that the player can never do better than 50% (random door strategy). So the solution based on these assumptions: Flip a coin. Don't switch if heads, switch if tails. 50% success rate always. On the other hand, if the player knew exactly what the host's strategy was, then the player may gain an advantage. If the host's strategy gives a higher-than-50% success rate for switching (such as Monty Hall), then the player switches. If the host's strategy gives a lower-than-50% success rate for switching (such as, host always opens car door if player initially selected goat door), then the player does not switch.
Warp wrote:
More puzzlingly, even if you do know, why would that make any difference?
It's called strategy. It exists just about everywhere (we're on a gaming site, even). Whether only one round is performed or not is irrelevant. Every round has a success probability, even when there is only one.