[R] Drawing random numbers from Uniform distribution with infinite range
@vi@e@gross m@iii@g oii gm@ii@com
@vi@e@gross m@iii@g oii gm@ii@com
Mon Jul 28 23:00:30 CEST 2025
If you think a bit, the requirement is silly. In computers, "real numbers"
are not a real thing. They are approximations with limits in several ways,
and some of these limits cannot be surmounted except perhaps someday with
quantum computers which may extend the range but are not likely to totally
do what you ask.
Pick a bizarrely large number such as a googolplex ( ten raised to the
googol power) and ask what a typical number chosen between 0 and this
selected number is? A typical number, say an integer, is not likely to be
in the miniscule range of 0 to the amount an integer on your machine holds.
Even if you use python-style extended integers, which are not a normal part
of R, the number of digits in such a random number may exceed the memory
available on your machine, or even the combined machines on our planet.
Picking a small enough number of something like -1,000,000,000 to 1,000,000,
000 has a probably approaching zero. Even using floating point in something
like 64 bits is rapidly overwhelmed.
Now, substitute a limit of infinity and negative infinity into the problem.
In a mathematical sense, the average number chosen between say zero and
infinity would be the nonsensical value of ∞/2 which is also ∞. Picking N
values between -∞ and +∞ does not seem helpful for almost any purpose. The
results cannot be graphed for example.
And, picking a random number between zero and one can be magnified only up
to a point as the number of valid digits is limited.
And, as many have pointed out, when you leave the Platonic Mathematical
universe and descend to using ANY computer language, such as R, the only
valid large value that the machine can handle is ∞ itself, not as a
measured amount, but as a concept.
Would your need be met by simply choosing large numbers for the range that
do not propagate infinities in the software but are representative enough?
As noted by others, you at least may need to stay under half the largest
number a machine allows unless you use a package supporting indefinite
precision numbers. But then, built-in functions are not expected to support
these numbers. The mathematics of density functions suggests that the
probability of choosing something specific like pi to infinite digits in an
infinite distribution is zero as 1/∞ is mathematically zero.
I am curious what reason you have chosen to work on this problem and wonder
if a more carefully chosen set of requirements meet your need.
-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of Daniel Lobo
Sent: Monday, July 28, 2025 12:30 PM
To: Rui Barradas <ruipbarradas using sapo.pt>
Cc: r-help using r-project.org
Subject: Re: [R] Drawing random numbers from Uniform distribution with
infinite range
Many thanks for your guidance. However my original problem is, how to
select n points in the Real line randomly without any preference of
any particular probability distribution?
On Mon, 28 Jul 2025 at 21:45, Rui Barradas <ruipbarradas using sapo.pt> wrote:
>
> On 7/28/2025 5:00 PM, Daniel Lobo wrote:
> > Hi,
> >
> > I want to draw a set of random number from Uniform distribution where
> > Support is the entire Real line.
> >
> > runif(4, min = -Inf, max = Inf)
> >
> > However it produces all NAN
> >
> > Could you please help with the right approach?
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
https://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> Hello,
>
>
> What you are asking doesn't make sense.
> The uniform distribution's PDF is
>
> f(x;a, b) = 1/abs(b - a) if x in [a, b]
> 0 otherwise
>
> So what you have is 1/abs(Inf - -Inf) = 1/abs(Inf) = 0.
>
> And the cumulative distribution function is even worse, it will give you
> the indeterminate Inf/Inf.
> See the Wikipedia on the uniform distribution [1].
>
>
> [1] https://en.wikipedia.org/wiki/Continuous_uniform_distribution
______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list