Hi Theo,
Theo de Raadt wrote on Sat, Dec 21, 2019 at 04:29:24PM -0700:
> Ingo Schwarze <[email protected]> wrote:
>> Alexander Nasonov wrote on Fri, Dec 20, 2019 at 08:33:40PM +0000:
>>> [email protected] wrote:
>>>> Clarify that drand48 returns values not including 1.0.
>>> It's not clear from the documentation whether drand48 can generate
>>> a denormal number. If it can't, you can exclude 0.0 because it's
>>> a denormal ;-)
>> Looking at our code in lib/libc/stdlib/drand48.c, i conclude that
>> drand48(3) does return 0.0 with a probability of 2^-48.
>>
>> More generally, the function returns a uniform distribution of
>> numbers from the set {2^-48 * n | n integer and 0 <= n < 2^48}.
>>
>> Talking about loading bits into the mantissa and adjusting the
>> exponent feels mildly confusing, given that the distribution is
>> simply uniform over a fixed finite set. I'm not sending a patch
>> because i never looked at how floating point representation works
>> internally, so i would likely only make matters worse.
> In which mode, the deterministic mode or the actual random mode? :)
You are right, it's thrilling to talk about probability distributions in
deterministic mode! Here we go, in deterministic mode, the distribution
is as follows:
* p=1 for the deterministic value requested by the user
* p=0 for any other value
The integral of this probability measure over the whole sample space,
as expected, is 1.
Yours,
;-)
P.S.
Please, everybody refrain from sending a patch adding the above
information to the manual page. Describing the distribution in
actual random mode seems sufficient to me.