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.(adsbygoogle = window.adsbygoogle || []).push({});

Is this correct? It seems counter intuitive.

--code--:

Code (Text):

#!/usr/bin/python3

import sys

import random

x = int(sys.argv[1])

a = random.randint(0,x)

b = random.randint(0,x)

steps = 1

combos = x**2

while a != b:

print('[{} {}]'.format(a,b), end=' ')

a = random.randint(0,x)

b = random.randint(0,x)

steps += 1

percent = (steps / combos) * 100

print()

print()

print('[{} ! {}]'.format(a,b), end=' ')

print('equality!'.upper())

print('steps'.upper(), steps)

print('possble combinations = {}'.format(combos))

print('explored {}% possibilitys'.format(percent))

**Physics Forums - The Fusion of Science and Community**

# Likelihood of pairs in a range?

Know someone interested in this topic? Share a link to this question via email,
Google+,
Twitter, or
Facebook

- Similar discussions for: Likelihood of pairs in a range?

Loading...

**Physics Forums - The Fusion of Science and Community**