Open Side Menu Go to the Top
Register
confusing probability problem confusing probability problem

06-07-2016 , 12:31 AM
A pack of 40 cards (four suits numbered 1-10) are placed in random order on the floor. The positions they're placed in are numbered as:

[1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5]

What is the probability of an arrangement that meets the following criteria:

A card numbered 1 can't be placed in position labeled 1, and the same restriction applies to cards 2-7; cards 8-10 can be placed anywhere.
confusing probability problem Quote
06-07-2016 , 03:30 AM
As you may know, this type of problem deals with "derangements". I think we may have had a few threads over the years similar to this. If you are interested, you may want to google the term and/or search for it here on 2+2.

Anyway, since this is a fairly complex question (not your run-of-the-mill derangement), I decided to code up a simple simulation. On modern computers it takes just a few minutes to code the simulation and run millions of trials, so that is often the path of least resistance.

I find that in 100,000,000 trials, there were 1,412,031 that meet your criteria of having no "1" in the first pile, no "2" in the second pile, ..., no "7" in the seventh pile. Of course, this is 1.412%.

I always caution that there is the possibility that I coded the simulation incorrectly, so it is wise to wait for confirmation from others.

An exact answer could probably be found via the Principle of Inclusion-Exclusion (PIE). We have several people on this forum who are well-versed in the machinations of PIE so perhaps something may be forthcoming on that front.
confusing probability problem Quote
06-10-2016 , 01:23 PM
I ran 7 separate simulations of 1,000,000 trials and got an average of 1.437%.

Every simulation was between 1.435 - 1.439, so I don't think it's variance error. Interesting because we are quite close, but seems like at least one of us made some small mistake in the code. Or perhaps the randomness wasn't great. I used PHP "shuffle" to randomize.
confusing probability problem Quote
06-10-2016 , 05:30 PM
Quote:
Originally Posted by Yoshi63
I ran 7 separate simulations of 1,000,000 trials and got an average of 1.437%.

Every simulation was between 1.435 - 1.439, so I don't think it's variance error. Interesting because we are quite close, but seems like at least one of us made some small mistake in the code. Or perhaps the randomness wasn't great. I used PHP "shuffle" to randomize.
Thanks for doing this!

Interesting results. They look a little strange to me since the spread "should" be larger over such simulations if totally random.

Let's do a quick calculation. Using the well-known formula for standard deviation of the number of successes in 1,000,000 binomial trials with a success probability of 1.437%, the standard deviation is around 119. Meaning that getting 7 "cases" all within 20 or so of the mean looks suspicious.

I just ran 10 one-million trial simulations for comparison. The number of successes I got were:

14,255
14,040
13,986
14,081
14,269
13,996
14,061
14,300
14,025
14,130

Taking the finite-adjusted standard deviation of these numbers yields 118 which is what we'd expect (whether we use 1.412% or 1.437%).

I have double-checked my simulation code and have not found any error, though it is notoriously difficult to find one's own errors of course.

To summarize, thanks for doing your simulations. I think we can take it as confirmation that the true probability OP is seeking is around 1.4%. It also looks like your "randomization" technique may not be truly random. (Not a knock on you but on the randomization technique used by the software that you are using.)

Thanks again.
confusing probability problem Quote
06-10-2016 , 09:08 PM
Nice. I thought the variance on mine seemed kind of tight.

So I went back and changed one small thing in my code. Instead of creating a fresh array from 1-40 for each iteration and shuffling once, I had it re-shuffle from the previously shuffled array. I ran 20 different 1M simulations this way and now get 1.4091% with a standard deviation of 118.2 for each sim.

Strange that this would matter, but shows the function has some flaws in the randomness that get ironed out over multiple shuffles. Even more strange, if I use my original method but shuffle 10 times from fresh each time, I get 1.425 with stdev of 605...

Anyways looks like the 1.412% figure should be about good!
confusing probability problem Quote
06-10-2016 , 10:37 PM
Good to know that after the randomization issue was ironed out we arrive at virtually the same answer.

By the way, in the past I was bedeviled by a crappy random number generator (RNG) in software I had been using. I was getting simulation results that just couldn't be true and the more trials I ran the worse results I obtained. Drove me bonkers before I realized that the RNG the software was using was really poor. The silver lining of the story is that it caused me to start using new and better software for my simulations.
confusing probability problem Quote

      
m