Or rlogis(1e6, scale=.5) which is the same thing. But the logistic distribution is in no reasonable sense a uniform on the entire line, any more than the Gaussian is.
(Some notion of a "random real" is involved in Benford's law of first digits, but that involves having a uniform distribution of log(X) and then increasing the range.) -pd > On 30 Jul 2025, at 14:11 , Richard O'Keefe <rao...@gmail.com> wrote: > > 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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ 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.