[R] Drawing random numbers from Uniform distribution with infinite range
Richard O'Keefe
r@oknz @end|ng |rom gm@||@com
Tue Jul 29 22:44:20 CEST 2025
The uniform distribution with infinite range gives each possible
answer infinitesimal probability of being chosen.
In the standard real numbers, that probability is ZERO.
In fact, the probability of getting a number in *any* prespecified
finite range is the same, ZERO.
One such finite range is the numbers that can be represented in floating-point.
So you are with certainty not going to draw a representable number.
A complete answer to your question is thus
ifelse(runif(N) < 0.5, 1, -1)/0
Why do you think you need this?
On Tue, 29 Jul 2025 at 04:01, Daniel Lobo <danielobo9976 using gmail.com> 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.
More information about the R-help
mailing list