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 <danielobo9...@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@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.

______________________________________________
R-help@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.

Reply via email to