Richard O'Keefe
2025-Jul-29 20:56 UTC
[R] Drawing random numbers from Uniform distribution with infinite range
I meant to write "gives each finite interval an infinitesimal probability of the result landing there." Which I eventually got to. And we weren't talking about finite range uniforms., which was sort of the point. On Wed, 30 Jul 2025 at 08:48, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:> > On 2025-07-29 4:44 p.m., Richard O'Keefe wrote: > > The uniform distribution with infinite range gives each possible > > answer infinitesimal probability of being chosen. > > That's also true of a finite range uniform distribution. > > > In the standard real numbers, that probability is ZERO. > > So is that. > > > In fact, the probability of getting a number in *any* prespecified > > finite range is the same, ZERO. > > That's not true for the finite range version, only the improper one. > > Duncan Murdoch > > > 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 at 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 at 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 at 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. >
Ray Chiruka
2025-Jul-30 10:44 UTC
[R] Drawing random numbers from Uniform distribution with infinite range
Tfr On Tue, 29 Jul 2025, 23:15 Richard O'Keefe, <raoknz at gmail.com> wrote:> I meant to write "gives each finite interval an infinitesimal > probability of the result landing there." > Which I eventually got to. And we weren't talking about finite range > uniforms., which was sort > of the point. > > On Wed, 30 Jul 2025 at 08:48, Duncan Murdoch <murdoch.duncan at gmail.com> > wrote: > > > > On 2025-07-29 4:44 p.m., Richard O'Keefe wrote: > > > The uniform distribution with infinite range gives each possible > > > answer infinitesimal probability of being chosen. > > > > That's also true of a finite range uniform distribution. > > > > > In the standard real numbers, that probability is ZERO. > > > > So is that. > > > > > In fact, the probability of getting a number in *any* prespecified > > > finite range is the same, ZERO. > > > > That's not true for the finite range version, only the improper one. > > > > Duncan Murdoch > > > > > 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 at 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 at 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 at 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 at 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. >[[alternative HTML version deleted]]