Let's look at something that *would* work if it were not that IEEE doubles are relatively small discrete set,.
Suppose we had two things. - a U(0,1) uniform random generator able to generate any *real* in the range 0 .. 1 - an implementation of atanh() that works for any real in the range 0 .. 1 and can return any real number. Then atanh(runif(n)*2 - 1) would do pretty much what you want,. Try it in R. f <- function (n = 1000000) atanh(runif(n)*2 - 1) summary(f()) It turns out that working with *representable* numbers means that the results of f() are limited to roughly -18,.4 to 18.4, and with n = 1000000 the extremes are almost always around 7. Something that, for actual real numbers, could return *any* real, for representable numbers can only return -18-and-a-bit to +18-and-a-bit. This suggests a completely different approach to your original problem, whatever it is. Instead of working with the entire real line, transform your problem to work with the interval (0,1). 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.