Register to reply 
Likelihood of pairs in a range? 
Share this thread: 
#1
Jan1714, 06:37 AM

P: 1

Running a computer script (included below) I was testing to see how long it would take to match two numbers when selected at random from within a range. To my surprise the percentage of possibilities explored before finding a correct answer decreased as i raised the range.
Is this correct? It seems counter intuitive. code:



#2
Jan1714, 09:53 AM

P: 907

Each pair selected has a 1/x probability of being a match. It does not matter what the first pair member is. The second pair member has 1/x probability of matching. The expected number of guesses to get a match is going to be around x.
You are looking at the ratio of x to x^{2}. Of course this decreases as x increases. 


#3
Jan1714, 10:15 AM

P: 82

I'm not familiar with python, but if you want to do some experimentation with random numbers, you probably want to make sure first of all that you are using something better than the default random number method available in the language. Perhaps consider the following and see if that changes the result:
"Warning The pseudorandom generators of this module should not be used for security purposes. Use os.urandom() or SystemRandom if you require a cryptographically secure pseudorandom number generator. http://docs.python.org/2/library/random.html" 


#4
Jan1714, 10:54 AM

Mentor
P: 15,065

Likelihood of pairs in a range?



Register to reply 
Related Discussions  
Suppose A and B are n × n matrices. Show that range(AB) ⊆ range(A)  Calculus & Beyond Homework  4  
Suppose A and B are n × n matrices. Show that range(AB) ⊆ range(A)  Calculus & Beyond Homework  5  
Physics projectile problem  finding vertical range using the horizontal range  Introductory Physics Homework  1  
Photon Pairs  Can photons travel in pairs?  Quantum Physics  7  
Pairs of primes separated by a single number are called prime pairs  Fun, Photos & Games  12 