Uniformly distributed rationals Is there any algorithm, function or formula $f(n)$, which is a bijection between the positive integers and the rationals in $(0,1)$, with the condition, that for all real numbers $a,b,x$ with $0&lt;a&lt;b&lt;1&lt;x$, if we let $i(x)$ be the number of distinct integers $0&lt;n_j&lt;x$ which satisfy $a&lt;f(n_j)&lt;b$, then we have $\lim_{x\rightarrow\infty}i(x)/x=b-a$?
You are looking for an equidistributed sequence of rationals that uses every rational exactly once.  The Van der Corput sequence mentioned by GEdgar comes close, except that it misses some of the rationals.  But you can just throw in the missing numbers, as long as you spread them out.

For instance, the binary Van der Corput sequence uses all the dyadic rationals.  If you enumerate the non-dyadic rationals and insert the $k$th one into the sequence at position $2^k$, say, you can check that the new sequence is still equidistributed.  The key is that of the first $N$ values in the sequence, only $o(N)$ have been changed.
(I may have misinterpreted this question. I came across this question while wondering if it is possible to construct a "uniform" random variable that generates rationals. I think it's impossible.)

Consider a random variable $X$ over the rationals in (0,1). One way to define a "uniform" distribution is the following rule:

$$ \mathrm{P}(a &lt; X &lt; a+\epsilon) = \epsilon $$

for any $0 &lt; a &lt; a+\epsilon &lt;1$. This says that the probability that a number drawn from $X$ is in the interval $(a,a+\epsilon)$ equals $\epsilon$ and, in particular, the probability is independent of $a$.

The probability that $X$ equals any particular rational, $r$, must be zero. A proof by contradiction: If there existed an $r$ such that

$$ \mathrm{P}(X = r) = p_r &gt; 0 $$

then one could construct an interval around $r$ which is narrower than $p_r$, such as $(r-\frac13 p_r, r+\frac13 p_r)$. By our earlier rule, it should be the case that 

$$ \mathrm{P}(r-\frac13 p_r &lt; X &lt; r+\frac13 p_r) = \frac23 p_r $$

but this contradicts the assumption that there already exists a single element in that interval which has probability $p_r$. There is not enough probability mass in the arbitrarily-small interval to allow the individual rationals to have non-zero probabilities.

Therefore, the probability mass associated with any rational must be zero. (Or perhaps hyperreal.)

Now, it is trivial to construct a (possibly non-uniform) distribution over the rationals, which I'll call $Y$. Draw the denominator, $d$, from a suitable integer distribution (such as Geometric) and draw the numerator, $n$, uniformly from the range $0&lt;n&lt;d$. For each rational $r$, there will be a non-zero probability of it being generated from that simple scheme:

$$ \mathrm{P}(Y=r) &gt; 0 $$

and of course, these must sum to 1 to be a proper probability distribution:

$$ \sum_{r \in \mathcal{Q}} \mathrm{P}(Y=r) = 1 $$

Finally (and I'm not sure I've got this right...), the probabilities for every element in X (zero) are smaller than for every element in Y (non-zero).

$$ \forall r \qquad \mathrm{P}(Y=r) &gt; \mathrm{P}(X=r) $$

and therefore the sum for X, $ \sum_{r \in \mathcal{Q}} \mathrm{P}(X=r) $, can't possibly sum to 1. Every term in the sum for X is smaller than the corresponding term for Y. So such a distribution over the rationals cannot exist.

(This answer probably isn't novel, I'm not a specialist. But I am interested in this question. Any feedback appreciated.)