On Aug 18, 2019, at 06:20, Senhaji Rhazi hamza <hamza.senhajirh...@gmail.com> wrote: > > Hey Steven, > > I think there is a way to map x <- [1; + inf] to y <- [0;1] by putting y = 1/x
Well, that gives you a distribution from (0, 1] instead of [0. 1), which is technically not legal as a substitute for random, even though it’ll actually only matter 1 in about 2^42 runs. You could pass this to shuffle today and probably get away with it, so asking for the same in choice, etc. isn’t too outrageous. But it’s still hard to judge whether it’s a good suggestion, if we don’t actually know what you’re trying to accomplish. First, there’s no way random could even know that you needed anything transformed. The distribution functions don’t come with metadata describing their support, and, even if they did, a new lambda that you pass in wouldn’t. As far as it could possibly tell, you passed in something that claims to be a nullary function that returns values in [0, 1), and it is a nullary function, and that’s all it knows. More importantly, even if that weren’t a problem, 1/x is hardly the one and only one obvious guess at how to turn Pareto into something with the appropriate support. In fact, I suspect more people would probably want a shifted, scaled, and truncated Pareto if they asked for Pareto. (Much as people often tall about things like the mean of a Cauchy distribution, which doesn’t exist but can be approximated very well with the mean of a Cauchy distribution truncated to some very large maximum.) > But i think there is another issue to consider : > for example if we want to sort : > > random.choice(['a', 'b', 'c'], random=lambda: random.paretovariate(1.75)), we > should have a mapping > between the elements of the list (here :a,b,c) to [0, 1] and the reverser > mapping, having this mapping underline > that we have a notion of order and distance, "measurement" between the > elements, and it is not trivial to always > have a notion of "order" or "distance" between the elements we manipulate, > but it could be fun > to have this possibility. I’m not sure what all of this means. What are you sorting? Why are you passing paretovariate instead of 1/ that after you just talked about that? What is this reverser mapping? Why are you switching from probability concepts to metric theory halfway through the paragraph? Maybe it would help if you could explain what you expected this to do. What should the odds of a, b, and c be in your function? If we understood what you wanted, people could probably (a) explain the best way to do it today, (b) come up with a specific proposal for a way to make it easier, and (c) evaluate whether that proposal is a good idea. Or, alternatively, if you have a different example, one where you’d obviously want to use some existing [0, 1) distribution with choice or sample and don’t need to go through all this to explain it, that would help. The thing is, your proposal—to add a random argument to choice, choices, and sample—makes sense, but if your only example doesn’t make sense, it’s very hard to judge the proposal. It sounds like a good idea on the face of it. The only obvious problems are the limitations of only having a double rather than as many bits as needed, and coming from a PRNG with a limited period compared to 2^N for large N, both of which are if anything even bigger problems for shuffle, which already allows a random argument. So, why not choice and sample too? But if the only thing anyone wants from it is something that doesn’t make sense, then maybe we’re better off without it?
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/KGIMYGNZIXT5KDWNMTQRTZ5ZWXTDPT6L/ Code of Conduct: http://python.org/psf/codeofconduct/