Boost logo

Boost :

Subject: Re: [boost] [random][rational] Is there any standard way to generate a random rationals?
From: MJanes (max.jns_at_[hidden])
Date: 2015-03-10 06:29:52

Il giorno martedì 10 marzo 2015 11:14:26 UTC+1, Thorsten Ottosen ha scritto:

> Given a random double in some interval, would it be possible to
> calculate the nearest rational number?

there's no nearest rational number, as there are inifinetly many of them in
any bounded neighbourhood of any real number. Unless by nearest you mean
the nearest rational with the greatest representable denominator... but in
this case the result will not be uniform anymore. As said, uniformity (
meaning prob(x in [a,b])=b-a ) seems fundamentally impossible for rationals
for the aforementioned reasons ...

Boost list run by bdawes at, gregod at, cpdaniel at, john at