Senhaji Rhazi hamza writes: > I think there is a way to map x <- [1; + inf] to y <- [0;1] by > putting y = 1/x
I don't think that's the point. I'll put money on a poor choice of value for the random parameter in the example: the OP chose the Pareto variate because that's what he mentioned earlier. But there are plenty of distributions besides uniform that can be parametrized to have support included in [0,1]. To me, it also seems a little odd that random.choices supports only discrete populations (possibly with weights) but doesn't support float populations. I think r.choices(random=lambda: random.paretovariate(1.75), k=k) would be a nice way to spell "sample with replacement from Pareto distribution of size k". But as Steven d'Aprano points out, you can also spell it [ random.paretovariate(1.75) for _ in range(k) ] so there's no real need to generalize Random.choices. On the other hand, r.sample(random=lambda: random.paretovariate(1.75), k=k) doesn't make immediate sense to me. What does "sampling without replacement" mean if you don't have an explicit population? (Note that random.sample doesn't support weights for a similar reason, although it could support counts.) So this suggests to me that the proposed ``random`` parameter to sequence methods is actually a spurious generalization, and has different interpretations for different methods. So I'm not against this proposal at this point, but I think it needs to be fleshed out more, both in terms of the principle we're trying to implement, and some more detailed examples. Steve _______________________________________________ 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/JR3G22W4H3JTO4KC5DJGCTEZKI26KHUP/ Code of Conduct: http://python.org/psf/codeofconduct/