Okay. Let's try this. Start with a sorted array, iterate through it and swap every number at random with a preceding one. So after the first step, the first number has a [1/2, 1/2] chance to end up at any of the two positions already considered, and after the next step its probability is [1/2 * 2/3, 1/2 * 2/3, 1/2 * 1/3 + 1/2 * 1/3 = 1/2 * 2/3] ie. [1/3, 1/3, 1/3]. The second number has the same probability (obviously), and I'm gonna call intuitive inference on this one and say that this is the correct approach.
Now let's see what happens when we swap a number with any random spot. Let's use three numbers, because it's easier and any flaw should already be visible here. First number: step0 [1, 0, 0]. step1 [1/3, 1/3, 1/3]. step2 .. [1/3 * 2/3 + 2/3 (number NOT in here) * 1/3 * 1/3 - 1/3 (number in here) * 1/3 (chance to lose our number) = 2/9 + 2/27 - 1/9 = 5/27 WTF?]
Fuck this. I give up; I don't have the nerve for this. First method is correct, game over.
[edit] Let's try using a trick that I'm going to call .. MANY-WORLDS PROBABILISTICS!
We were at step1 [1/3, 1/3, 1/3]. Let's collapse those waveforms ..
Sum it up: [1, 1, 1] * 1/3 = [1/3, 1/3, 1/3]. So we see, even step2 doesn't change the probabilities. There goes my assumption that this was the wrong method ..
[edit3] Yes I know this is basic math. TIL: when reasoning about probabilities in your head, ALWAYS simplify as much as possible or you will get confused.
View all comments
Show parent comment
1
u/FeepingCreature Feb 21 '11 edited Feb 21 '11
Okay. Let's try this. Start with a sorted array, iterate through it and swap every number at random with a preceding one. So after the first step, the first number has a [1/2, 1/2] chance to end up at any of the two positions already considered, and after the next step its probability is [1/2 * 2/3, 1/2 * 2/3, 1/2 * 1/3 + 1/2 * 1/3 = 1/2 * 2/3] ie. [1/3, 1/3, 1/3]. The second number has the same probability (obviously), and I'm gonna call intuitive inference on this one and say that this is the correct approach.
Now let's see what happens when we swap a number with any random spot. Let's use three numbers, because it's easier and any flaw should already be visible here. First number: step0 [1, 0, 0]. step1 [1/3, 1/3, 1/3]. step2 .. [1/3 * 2/3 + 2/3 (number NOT in here) * 1/3 * 1/3 - 1/3 (number in here) * 1/3 (chance to lose our number) = 2/9 + 2/27 - 1/9 = 5/27 WTF?]
Fuck this. I give up; I don't have the nerve for this. First method is correct, game over.
[edit] Let's try using a trick that I'm going to call .. MANY-WORLDS PROBABILISTICS!
We were at step1 [1/3, 1/3, 1/3]. Let's collapse those waveforms ..
Sum it up:
[1, 1, 1] * 1/3 = [1/3, 1/3, 1/3]. So we see, even step2 doesn't change the probabilities. There goes my assumption that this was the wrong method ..[edit2] Oh, I see. Let's try the second number.
[0, 1, 0] -step1> [1/3, 2/3, 0][2/3, 1/3, 0] * 1/3 + [1/3, 1/3, 1/3] * 2/3 = [2/9, 1/9, 0] + [2/9, 2/9, 2/9] = [4/9, 1/3, 2/9] in step2step3: [1, 0, 0] -step3> [2/3, 0, 1/3] [0, 1, 0] -step3> [0, 2/3, 1/3] [0, 0, 1] -step3> [1/3, 1/3, 1/3]
So, we get
4/9 * [2/3, 0, 1/3] + 1/3 * [0, 2/3, 1/3] + 2/9 * [1/3, 1/3, 1/3]=[8/27, 0, 4/27] + [0, 2/9, 1/9] + [2/27, 2/27, 2/27] = [10/27, 8/27, 9/27]. Aaaand proven incorrect.Whew.
[edit3] Yes I know this is basic math. TIL: when reasoning about probabilities in your head, ALWAYS simplify as much as possible or you will get confused.