Re: Conveniently generating random numbers with TR1 random
Walter E Brown wrote:
[snip]
Thanks for the excellent information.
I see that you've separately now posted a question phrased in terms of
the intermediate document N2032, but I don't know why of all the
references I provided you would choose that one, clearly labeled
"version 2" and equally clearly succeeded by a "version 3" and a
"version 4".
More importantly, your question seems to misconstrue the nature of
"param_type" in the distributions. In particular, you wrote: "I see
with chagrin that the operator()(UniformRandomNumberGenerator& urng,
const param_type& parm) is still there. I don't understand why. The nice
thing is that the function is constrained to a specific integral type
param_type."
(1) I don't know why you believe that param_type is an integral type.
There's no such requirement.
(2) As stated in N1933, param_type and related functions "provide a
uniform interface so that distribution parameters can be manipulated
generically: it now becomes possible to write code that is independent
of any specific distribution."
Ok, I understand.
And finally, let me see if I understand your basic concern about the
interface to a distribution. Is it that you believe that the member
templates of the following form are superfluous?
template<class URNG>
result_type
..._distribution::operator()(URNG&, param_type const &)
If so, please let me know and I will be very happy to address that
specific issue.
Yes, that's the root of my question. More specifically, I'm not sure
what method to use when generating integers in a range [a, b]. My
understanding is that I could go two routes:
a) Call uniform_int<int>(a, b)(gen)
b) Call a + uniform_int<int>(whatever, whatever)(gen, b + 1)
Why are there two ways, and what are the tradeoffs guiding the choice of
using one of them?
Andrei
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]