Skip to main content
21 events
when toggle format what by license comment
May 22, 2017 at 4:29 audit First posts
May 22, 2017 at 5:21
May 22, 2017 at 3:47 audit First posts
May 22, 2017 at 4:15
May 19, 2017 at 8:10 audit First posts
May 19, 2017 at 8:11
May 11, 2017 at 13:47 audit First posts
May 11, 2017 at 13:48
May 8, 2017 at 8:23 audit First posts
May 8, 2017 at 8:24
Apr 27, 2017 at 20:36 audit First posts
Apr 27, 2017 at 21:29
Apr 27, 2017 at 12:55 audit First posts
Apr 27, 2017 at 12:56
Apr 25, 2017 at 11:41 comment added FooBar167 @MSeifert -- added mathematical proof.
Apr 25, 2017 at 11:36 history edited FooBar167 CC BY-SA 3.0
Added description.
Apr 25, 2017 at 11:26 history edited FooBar167 CC BY-SA 3.0
Added mathematical proof for 7th position. And it can be proved for all positions in the same way.
Apr 24, 2017 at 21:42 comment added MSeifert Yes, you're totally right. :) I forgot that 02341 could also produce 1234. I'm glad I did not remove my upvote based on my flawed argument. (even though I really liked your first approach). :)
Apr 24, 2017 at 21:32 comment added FooBar167 @MSeifert -- Lets take simpler example: list [0,1,2] and two unique digits not starting with 0. There are 3!==6 possibilities. Each possibility has probability 1/6. There are 2 leading zeros: [0,1,2] and [0,2,1]. If randomly swap leading 0 with the rest 2 positions, there are four combinations: [0,1,2]==>([1,0,2] and [2,1,0]); [0,2,1]==>([2,0,1] and [1,2,0]). Each of these four combinations have the same probability equal to 1/6 * 1/2 == 1/12. But these 4 combinations coincide with the rest 4 possibilities. So each possibility after random swap should have probability == 1/6 + 1/12.
Apr 24, 2017 at 21:18 comment added MSeifert I'm not really sure if that garantuees an even distribution. For example 1234 wouldn't hit the branch (say it would have a normalized probability of 1). But numbers like 1203 could be produced either by shuffling once (probability 1) and by drawing 0213 (granted it's a chance of 1/9th). Thus these would have a probability of ~1.1. This reasoning may be wrong (I'm not a statistician) and I personally liked the original approach (it was very simple and therefore elegant!). Even distribution wasn't part of the question so a skewed distribution would answer the question just fine.
Apr 24, 2017 at 20:49 history edited FooBar167 CC BY-SA 3.0
added 606 characters in body
Apr 24, 2017 at 20:30 comment added FooBar167 @MSeifert -- Yes. For example, take list [0,1,2] and combine only two unique random digits not starting from zero. There are only 3! == 6 possibilities: [0,1,2]; [0,2,1]; [1,0,2]; [1,2,0]; [2,0,1]; [2,1,0]. If I shift on one position, I'll have [1,2] and [2,1] twice as often than [1,0] and [2,0]. So I should use suggestion of Mitch and randomly swap leading zero with the second or the third position. This will give the same probabilities.
Apr 24, 2017 at 20:24 comment added FooBar167 @Mitch -- Yes, you're right. I'll fix my note according to your suggestion. And check it on [0,1,2] list with 2 unique digits not starting with 0. There are only 3! == 6 possibilities (easy to check).
Apr 24, 2017 at 20:00 comment added miradulo @foobar No, MSeifert has a point. Your current approach doesn't draw from the sample space uniformly. (I think) my suggestion fixes this though.
Apr 24, 2017 at 19:56 comment added miradulo e.g. random.shuffle(l); if l[0] == 0: pos = random.choice(range(1, 10)); l[0], l[pos] = l[pos], l[0]
Apr 24, 2017 at 19:50 comment added miradulo @MSeifert Ahh you're correct.. How about swapping zero with a random location in the list should a zero-leading number be drawn? Then we redistribute evenly back across the sample space in that case.
Apr 24, 2017 at 19:35 comment added MSeifert But the not every possible value is drawn with the same probability. Because for example 1234 and 01234 produce the same result while numbers containing a not-leading zero (e.g. 1023) have only one possibility to be drawn.
Apr 24, 2017 at 18:03 history answered FooBar167 CC BY-SA 3.0