[R] Drawing random numbers from Uniform distribution with infinite range
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Tue Jul 29 22:48:27 CEST 2025
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 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.
>
> ______________________________________________
> 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