Subject: Re: [boost] [random][rational] Is there any standard way to generate a random rationals?
From: Damian Vicino (damian.vicino_at_[hidden])
Date: 2015-03-10 06:35:24
> On Mar 10, 2015, at 11:29 AM, MJanes <max.jns_at_[hidden]> wrote:
> 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 â¦
Yes, probably for my particular case, the best I can get is a random integer for numerator after fixing the denominator in some number.
Making it be in [0-1] will be equivalent to make it between 0 and numerator in that case.
Thanks for the comments.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk