The implementation is tricky, but you can understand the distribution
looking at this "alternative" implementation:

(define (myrandom)
    #;(/ (+ (random 4294967087) 1) (+ 4294967087 1))
    (* (+ (random 4294967087) 1) 2.328306549295728e-10))

[it may have a tiny rounding difference]

Gustavo

Implementation for the current version of Racket (written in C)
https://github.com/racket/racket/blob/master/racket/src/racket/src/newrandom.inc

Implementation a version of Racket in the future (not next version)
(written in Scheme)
https://github.com/racket/racket/blob/master/racket/src/cs/rumble/random.ss




On Tue, Apr 2, 2019 at 2:14 PM <polarish...@gmail.com> wrote:

> Hello everyone,
>
> The specification of `random` function with zero arguments is only that a
> random inexact real numbers between 0 and 1 is generated. I have two quick
> questions about it,
>
> 1. Will all random inexact real numbers between 0 and 1 be eventually
> generated?
> 2. What's the distribution of the numbers generated? Uniformity is a
> little bit ambiguous here because it can mean either each floating-point
> number gets equal chance to be generated or its probability is proportional
> to the interval where real numbers get rounded to it.
>
> Thanks,
> Shaobo
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to