Re: rand48 replacement

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: rand48 replacement
Дата
Msg-id CAEZATCWnrVACs2FM219dSkh1ivic8KiGkPEVPtu-MO3nCOYm7A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: rand48 replacement  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: rand48 replacement
Список pgsql-hackers
On Sun, 4 Jul 2021 at 17:03, Fabien COELHO <coelho@cri.ensmp.fr> wrote:
>
> > As for determinism, the end result is still fully deterministic.
>
> The result is indeed deterministic of you call the function with the same
> range. However, if you change the range value in one place then sometimes
> the state can advance differently, so the determinism is lost, meaning
> that it depends on actual range values.

Ah yes, that's true. I can trivially reproduce that in other languages
too. For example, in python, if I call random.seed(0) and then
random.randrange() with the inputs 10,10,10 then the results are
6,6,0. But if the randrange() inputs are 10,1000,10 then the results
are 6,776,6. So the result from the 3rd call changes as a result of
changing the 2nd input. That's not entirely surprising. The important
property of determinism is that if I set a seed, and then make an
identical set of calls to the random API, the results will be
identical every time, so that it's possible to write tests with
predictable/repeatable results.

> I would work around that by
> deriving another 128 bit generator instead of splitmix 64 bit, but that is
> overkill.

Not really relevant now, but I'm pretty sure that's impossible to do.
You might try it as an interesting academic exercise, but I believe
it's a logical impossibility.

Regards,
Dean



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Fabien COELHO
Дата:
Сообщение: Re: rand48 replacement
Следующее
От: Tom Lane
Дата:
Сообщение: Excessive cost of OpClassCache flushes in CLOBBER_CACHE_ALWAYS mode