<div dir="ltr"><div dir="ltr">On Fri, Apr 19, 2019 at 5:16 AM Neal Becker <<a href="mailto:ndbecker2@gmail.com">ndbecker2@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The boost_random c++ library uses the terms 'generators' and<br>
'distributions'. Distributions are applied to generators.<br></blockquote><div><br></div><div>"distributions" is a little confusing in the context of scipy.stats.distributions, which a distribution corresponds to a particular probability distribution.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, Apr 19, 2019 at 7:54 AM Kevin Sheppard<br>
<<a href="mailto:kevin.k.sheppard@gmail.com" target="_blank">kevin.k.sheppard@gmail.com</a>> wrote:<br>
><br>
> > Rather than "base RNG", what about calling these classes a "random source"<br>
> or "random stream"? In particular, I would suggest defining two Python<br>
> classes:<br>
> > - np.random.Generator as a less redundant name for what is currently called<br>
> RandomGenerator<br>
> > - np.random.Source or np.random.Stream as an abstract base class for what<br>
> are currently called "base RNGs"<br>
><br>
> Naming is definitely hard. Simple RNGs are currently called basic RNGs which was inspired by mkl-random. 'source' sounds OK to me, but sort of hides the fact that these are the actual Psuedo RNGs. `stream` has a technical meaning (a single PRNG make produce multiple independent streams) and IMO should be avoided since this might lead to confusion. Perhaps source_rng (or in docs Source RNG)?<br>
><br>
> RandomGenerator is actually RandomTransformer, but I didn't like the latter name.<br>
><br>
> > There are also a couple of convenience attributes in the user-facing API<br>
> that I would suggest refining:<br>
> > - The "brng" attribute of RandomGenerator is not a very descriptive name. I<br>
> would prefer "stream" or "source", or the more explicit "base_rng" if we<br>
> stick with that term.<br>
> > - I don't think we need the "generator" property on base RNG objects. It is<br>
> fine to require writing np.random.Generator(base) instead. Looking at the<br>
> implementation, .generator caches the RandomGenerator objects it creates on<br>
> the base RNG, which creates a reference cycle. Yes, Python can garbage<br>
> collect reference cycles, but this is still a muddled data model.<br>
><br>
> The attribute name should match the final (descriptive) name, whatever it is. In RandomGen I am using the `basic_rng` attribute name, but this could be `source`. I also use a property so that the attribute can have a docstring attached for use in IPython. I think this is more user-friendly.<br>
><br>
> I think dropping the `generator` property on the basic RNGs is reasonable. It was a convenience but is awkward, and I always understood that it creates a cycle.<br>
><br>
> > Finally, why do we expose the np.random.gen object? I thought part of the<br>
> idea with the new API was to avoid global mutable state.<br>
><br>
> Module level functions are essential for quick experiments and should be provided. The only difference here is that the singleton `seed` and `state` are no longer exposed so that it isn't possible (using the exposed API) to set the seed.<br>
><br>
> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
<br>
<br>
<br>
-- <br>
Those who don't understand recursion are doomed to repeat it<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div></div>