C++ Logo


Advanced search

Re: Distributed random number ordering

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Thu, 13 May 2021 07:54:45 +0100

Is uniform_int_distribution really trivial?


-------- Original Message --------
From: Arthur O'Dwyer via Std-Proposals <std-proposals_at_[hidden]>
Sent: May 12, 2021 11:14:29 PM GMT+01:00
To: Std-Proposals <std-proposals_at_[hidden]>
Cc: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Subject: Re: [std-proposals] Distributed random number ordering

On Wed, May 12, 2021 at 5:51 PM Jason McKesson via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Wed, May 12, 2021 at 4:30 PM Lénárd Szolnoki via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > Hi,
> >
> > On the flip side mandating the algorithms also closes off further
> optimization opportunities from implementations. Also I wouldn't say that
> there are obvious algorithms to standardize even for discrete distributions.
> >
> > What comes to mind is adding an optional template parameter for
> distributions specifying a specific algorithm while having an
> implementation defined default.
> No, no "optional template parameters". I don't want to have to write
> `uniform_int_distribution<int, std::stable_distribution>`. I want to
> write `stable_uniform_int_distribution`, without having to specify the
> default type. And I imagine that implementation-wise, it's easier to
> just make a new type than to make a specialization, though this
> distinction is a bit trivial.

Even better: Get the source code of `stable_uniform_int_distribution` from
a third-party GitHub repository, where if you ever do discover that the
behavior differs across platforms, you can just file a bug and it's clearly
on them to fix it. If you rely on the Standard Library for this stuff, then
you have nowhere (or rather, five or six places) to file bug reports when
it doesn't work.

I see many reasons this should be on GitHub, and no reason this should be
in the Standard Library. (At least not for the computationally difficult
distributions with floating-point dependencies, like `normal_distribution`.
For `uniform_int_distribution` specifically, the Standard probably *should*
just mandate the algorithm, because it's relatively trivial.)


Received on 2021-05-13 01:55:00