
Probability and Statistics Basic Probability and Statistics Math Forum 
 LinkBack  Thread Tools  Display Modes 
May 11th, 2016, 01:35 AM  #1 
Newbie Joined: May 2016 From: Switzerland Posts: 2 Thanks: 0  Probability of one array containing all numbers of another array.
Hi Together, I wrote a small Programm for someone that does the Following. 1. Generates an Array with 20 unique random picked Numbers out of 40 (300340) 2. generates another Array with 20 Numbers of the same Range but this one is not Unique so Numbers can be double triple etc 3. Checks if All the Numbers of the 2nd no Unique Array are contained within the first unique array He thinks something is wrong with my Code cause he does not get Matches even after 10 000 000 runs. When i test it with smaller numbers it works fine. so i wonder if anyone here could tell me what is the Probability that the 2nd Array holds a number that is NOT contained in the first one (if you could explain how to calculate that if its not to complicated would be appreciated too) Thanks for your help Last edited by LordLoki; May 11th, 2016 at 01:37 AM. 
May 11th, 2016, 03:49 PM  #2 
Global Moderator Joined: May 2007 Posts: 6,730 Thanks: 689 
The probability that one of the second array matches one of the first is 1/2. Since the selections in the second array are all independent, the probability that all match is $\displaystyle (1/2)^{20}$ which is approximately 1 in a million. After 10 million runs, he should get around 10 matches. Note: you say 20 out of 40, but your range is 41 long. I assume a range of 40. 
May 12th, 2016, 06:31 AM  #3 
Newbie Joined: May 2016 From: Switzerland Posts: 2 Thanks: 0 
Hi mathman, Thanks for your Answer. Now that i see your answer it makes sense. Before i was looking more from a Lottery perspective thinking of the chance to get 20 out of 41 which lead me to believe the chance should be much lower. Btw you are correct it should be 20 out of 41 and if i got the Math right the chance of that is (1/2.05)20 wich should be approximately 6 in 10 million Thanks a lot and have a nice day 

Tags 
array, numbers, probability 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Modulo of an array of Complex Numbers, NPHard?  jeffreyncook  New Users  0  November 26th, 2015 03:01 PM 
Arbitrary arrangement of numbers in square array  Daltohn  Number Theory  2  October 11th, 2015 12:27 PM 
Rotate an array  NotYoung  Trigonometry  0  April 29th, 2015 07:47 AM 
Exercise concerning an array of integers mod p  icemanfan  Number Theory  0  August 31st, 2012 11:55 AM 
Logarithmic equation from a data array.  nickleonard100  Algebra  0  March 13th, 2012 03:13 AM 