# Probability of rounding off a fraction to an even number

In a quiz the following question was asked :

""Let x and y be two random numbers between 0 and 1. What is the probability that $\frac{x}{y}$ rounds to an even number?""

My friend calculated the answer to be $$\frac{5}{4}-\frac{\pi}{4}$$

which is roughly equal to 46 percent. I don't know whether his answer is definitely correct but could not find any flaws in his reasoning or calculation. So my question arises as follows:

Since x/y has values ranging from $0$ to infinity, why isn't the probability of rounding x/y to an even or odd number equal.

$\mathbf{EDIT:}$My friend used probability spaces in his answer. He plotted the two numbers x and y on a graph with both x and y varying from $0$ to $1$. This gives us a unit square. Then he calculated the area of the regions of the square which sastisfied the condition that x/y rounds to an even number. This gave him an infinite number of triangles with decreasing area. He applied summation on the areas of the triangles to get the answer.

• Can you describe your friend's idea? Aug 2, 2014 at 7:45

The probability that $\frac{x}{y}$ rounds to $0$, i.e that $2x \lt y$, is $\frac14$.

The probability that $\frac{x}{y}$ rounds to $2$ , i.e that $3y \le 2x \lt 5y$, is $\frac13-\frac15$, and similarly rounding to $4$ is $\frac17-\frac19$, to $6$ is $\frac1{11}-\frac1{13}$, and so on.

Since $1 - \frac13+\frac15-\frac17+\frac19-\frac1{11}+\frac1{13}- \cdots = \frac\pi{4}$, the probability of rounding to an even number is $\frac{1}{4}+1-\frac\pi{4}$ which is the result your friend had.

Your friend's diagram probably looked something like this

with the black areas corresponding to "rounding to even". There is no reason to expect the black and white areas to be the same: rounding to $1$ with a probability of $\frac{5}{12}$ is more likely than any other result.

As an empirical check using R:

set.seed(1)
cases <- 1000000
x <- runif(cases)
y <- runif(cases)
z <- round(x/y, 0)
mean( z/2 == floor(z/2) ) # even


gives

0.464628


compared with $\frac{5}{4}-\frac{\pi}{4} \approx 0.4646018$.